如何调用:: CreateProcess在c ++中以启动Windows可执行文件? [英] How do I call ::CreateProcess in c++ to launch a Windows executable?
本文介绍了如何调用:: CreateProcess在c ++中以启动Windows可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
寻找一个例子:
- 启动EXE
- 等待EXE
解决方案正确地关闭所有句柄。 / div>
这样的东西:
STARTUPINFO info = {sizeof(info)};
PROCESS_INFORMATION processInfo;
if(CreateProcess(path,cmd,NULL,NULL,TRUE,0,NULL,NULL,& info,& processInfo))
{
WaitForSingleObject(processInfo.hProcess,INFINITE) ;
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
Looking for an example that:
- Launches an EXE
- Waits for the EXE to finish.
- Properly closes all the handles when the executable finishes.
解决方案
Something like this:
STARTUPINFO info={sizeof(info)};
PROCESS_INFORMATION processInfo;
if (CreateProcess(path, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo))
{
WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
这篇关于如何调用:: CreateProcess在c ++中以启动Windows可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文