Windows CE下类似Process.Start功能的解决方法

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 );
    
  [DllImport("CoreDll.dll")]
  private extern static Int32 GetLastError();
    
  [DllImport("CoreDll.dll")]
  private extern static Int32 WaitForSingleObject(  IntPtr Handle,Int32 Wait);

public static bool CreateProcess( String ExeName, String CmdLine, ProcessInfo pi )
  {
   Int32 INFINITE;
   unchecked {INFINITE = (int)0xFFFFFFFF;}
    
   if ( pi == null )
    pi = new ProcessInfo();
   byte [] si = new byte[128];
   CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
    0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
   WaitForSingleObject(pi.hProcess,INFINITE);
   return true;
  }

private void btnExecute_Click(object sender, System.EventArgs e)
  {

   String progPath = "iexplore.exe";//这里就是你要执行的程式路径名称
   ProcessInfo pi = new ProcessInfo();
   if (CreateProcess(progPath, "", pi) )
   {
    MessageBox.Show("Success! PID = " + pi.ProcessId.ToString());
   }
   else
   {
    MessageBox.Show("Failed! System Error = " + GetLastError().ToString());
   }  
 }

你可能感兴趣的:(windows,object,String,System,Class,byte)