韩冰 发表于 2005-1-26 01:30

使用CreateProcess()函数

<P>使用CreateProcess()函数
</P>
<P> 以下是一个使用CreateProcess()函数的例子:
void CreateChildProcessAndWaitUntilDone(const AnsiString&amp; strCmdLine)
{</P>
<P>PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;</P>
<P>// 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;</P>
<P>
// Create the child process.
CreateProcess(</P>
<P>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
&amp;siStartInfo, // STARTUPINFO pointer
&amp;piProcInfo); // receives PROCESS_INFORMATION</P>
<P>// Wait for the processs to finish
DWORD rc = WaitForSingleObject(
piProcInfo.hProcess, // process handle
INFINITE);
}

</P>
页: [1]
查看完整版本: 使用CreateProcess()函数