开发者

create processes in visual c++

i am using visual c++ 2010 i want to learn crea开发者_运维百科te processes in c++ can anybody help where find tutorial or does here exist book? thanks


You can use the below snippet to create process. Just replace the bold part below with the path of the executable which needs to be run.

PROCESS_INFORMATION processInfo; //we get this as an [out] parameter
STARTUPINFO startupInfo; //this is an [in] parameter
memset(&startupInfo,0, sizeof(startupInfo));
memset(&processInfo,0, sizeof(processInfo));

startupInfo.cb = sizeof startupInfo ;

if (CreateProcess("**Executable_Path**", NULL, NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo))
{
   // If process is created successfully

   WaitForSingleObject(processInfo.hProcess,INFINITE);
   CloseHandle(processInfo.hThread);
   CloseHandle(processInfo.hProcess);
}
else
{
   //Cannot create process.
}


Check Win API CrateProcess function:

http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx


Please refer MSDN, the best source for Microsoft related technologies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜