WEB开发网
开发学院软件开发C++ 使用CreateProcess()函数 阅读

使用CreateProcess()函数

 2008-03-08 21:56:17 来源:WEB开发网   
核心提示:以下是一个使用CreatePRocess()函数的例子: void CreateChildProcessAndWaitUntilDone(const AnsiString& strCmdLine) {PROCESS_INFORMATION piprocInfo; STARTUPINFO siStartInfo;// S

  以下是一个使用CreatePRocess()函数的例子:
void CreateChildProcessAndWaitUntilDone(const AnsiString& strCmdLine)
{

PROCESS_INFORMATION piprocInfo;
STARTUPINFO siStartInfo;

// Set up members of STARTUPINFO strUCture.
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.lpReserved = NULL;
siStartInfo.lpReserved2 = NULL;
siStartInfo.cbReserved2 = 0;
siStartInfo.lpDesktop = NULL;
siStartInfo.dwFlags = 0;


// Create the child process.
CreateProcess(

NULL,
strCmdLine.c_str(),
NULL, // process security attributes
NULL, // primary thread security attributes
0, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current Directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo); // receives PROCESS_INFORMATION

// Wait for the processs to finish
DWord rc = WaitForSingleObject(
piProcInfo.hProcess, // process handle
INFINITE);
}

Tags:使用 CreateProcess 函数

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接