当前位置导航:炫浪网>>网络学院>>编程开发>>C++教程>>C++进阶与实例

使用CreateProcess()函数

    以下是一个使用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);
}

相关内容
赞助商链接