在WinCE下使用C#来打开一个外部程序

以打开一个IE为例,介绍如何在WinCE下使用C#来打开一个外部文件:

 

using System.Runtime.InteropServices;
 
[DllImport("coredll.Dll",  EntryPoint="CreateProcess",  SetLastError=true)] 
extern static int CreateProcess(string strImageName, string strCmdLine, IntPtr pProcessAttributes,   
                            IntPtr pThreadAttributes, int bInheritsHandle, int dwCreationFlags, 
                            IntPtr pEnvironment, IntPtr pCurrentDir, IntPtr  bArray, ProcessInfo oProc); 

public  class  ProcessInfo 
{ 
   public  Int32  hProcess; 
   public  Int32  hThread; 
   public  Int32  ProcessID; 
   public  Int32  ThreadID; 
} 

private void button_Click(object sender, System.EventArgs e) 
{ 
    ProcessInfo  pi  =  new  ProcessInfo(); 
    CreateProcess("\\windows\\iesample.exe", 
                     "\\HardDisk\\Readme.htm", IntPtr.Zero, 
                   IntPtr.Zero, 0, 0, IntPtr.Zero,  IntPtr.Zero,  IntPtr.Zero,  pi);   
} 
posted @ 2009-03-16 23:15  木瓜脑袋  阅读(1681)  评论(0编辑  收藏  举报