首页  ·  知识 ·  移动开发
WindowsMobile程序自动更新
网友     Wphone  编辑:dezai   图片来源:网络
ProcessInfo pi = new ProcessInfo(); string save_path = quot; file://my/font col

ProcessInfo pi = new ProcessInfo();
string save_path = "\\My Documents\\file1.CAB";
// 用wceload.exe启动CAB安装程序
CreateProcess(@"\Windows\wceload.exe", "\"" + save_path + "\"", pi);
//string new_path = @"\Program Files\file1\FileOpt.exe";
//CreateProcess(@"\Windows\wceload.exe", "\"" + new_path + "\"", pi);
try
{
// 启动更新好的程序
System.Diagnostics.Process.Start(@"\Program Files\file1\FileOpt.exe", "");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
// 关闭当前页面
this.Close();

public static bool CreateProcess(String ExeName, String CmdLine, ProcessInfo pi)
{
if (pi == null)
pi = new ProcessInfo();

byte[] si = new byte[128];
return CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, si, pi) != 0;
}

public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}

[DllImport("CoreDll.DLL", SetLastError = true)]
private extern static int CreateProcess(String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte[] si,
ProcessInfo pi);

本文作者:网友 来源:网络
CIO之家 www.ciozj.com 微信公众号:imciow
    >>频道首页  >>网站首页   纠错  >>投诉
版权声明:CIO之家尊重行业规范,每篇文章都注明有明确的作者和来源;CIO之家的原创文章,请转载时务必注明文章作者和来源;
延伸阅读
也许感兴趣的
我们推荐的
主题最新
看看其它的