您的位置:首页 > 其它

Windows Mobile/Windows CE开发技巧 —— 创建一个新进程

2016-12-11 20:04 716 查看
使用API的CreateProcess方法,可以在代码中动态地创建一个新程序的进程。

以下为创建一个任务管理器进程的例子:

[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;
}

ProcessInfo pi = new ProcessInfo();
CreateProcess("\\windows\\TaskMgr.exe",
"", IntPtr.Zero,
IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, pi);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐