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);
本文作者:网友 来源:网络