如何制作自动安装包?

dangyaofei 2010-01-08 01:38:47
我向实现软自动更新,每次更新后,程序能自动安装,
...全文
95 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wt0731 2010-01-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 feishanm 的回复:]
软件有更新->启动更新软件,并关闭主软件->更新软件下载更新文件,下载完后替换文件或安装->启动主软件,并关闭更新软件
[/Quote]
逻辑就这样,见1楼。
当中要自动安装,需要用到ShellExecuteEx,来安装你的cab.要是替换文件方式的话,用CreateProcess。


#region PInvoke defintions
class SHELLEXECUTEEX
{
public UInt32 cbSize;
public UInt32 fMask;
public IntPtr hwnd;
public IntPtr lpVerb;
public IntPtr lpFile;
public IntPtr lpParameters;
public IntPtr lpDirectory;
public int nShow;
public IntPtr hInstApp;

// Optional members
public IntPtr lpIDList;
public IntPtr lpClass;
public IntPtr hkeyClass;
public UInt32 dwHotKey;
public IntPtr hIcon;
public IntPtr hProcess;
}

[DllImport("coredll")]
extern static int ShellExecuteEx( SHELLEXECUTEEX ex );

[DllImport("coredll")]
extern static IntPtr LocalAlloc( int flags, int size );

[DllImport("coredll")]
extern static void LocalFree( IntPtr ptr );

[DllImport("coredll")]
public static extern IntPtr GetCapture();

[DllImport("coredll")]
public static extern IntPtr MoveWindow(IntPtr hWnd, int X, int Y, int Width, int Height, bool Repaint);

[DllImport("coredll")]
public static extern int GetWindowLong(IntPtr hWnd, int nItem);

[DllImport("coredll")]
public static extern void SetWindowLong(IntPtr hWnd, int nItem, int nValue);

public const int GWL_STYLE = (-16);
public const int GWL_EXSTYLE = (-20);
public const int GWL_USERDATA = (-21);
public const int GWL_ID = (-12);

public const int WS_BORDER = 0x00800000;
public const int WS_CAPTION = 0x00C00000;

#endregion

  [DllImport("coredll.Dll")]
private static extern int CreateProcess(string strImageName, string strCmdLine, IntPtr pProcessAttributes, IntPtr pThreadAttributes, int bInheritsHandle, int dwCreationFlags, IntPtr pEnvironment, IntPtr pCurrentDir, Byte[] bArray, ProcessInfo oProc);
dc212009 2010-01-08
  • 打赏
  • 举报
回复
关注,马上也要做这个功能了
feishanm 2010-01-08
  • 打赏
  • 举报
回复
软件有更新->启动更新软件,并关闭主软件->更新软件下载更新文件,下载完后替换文件或安装->启动主软件,并关闭更新软件

7,655

社区成员

发帖
与我相关
我的任务
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
  • Windows客户端开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧