我想通过mfc调用一个进程,但我需要新的exe必须假装像一个子对话框。因此,如果新的exe不会关闭,用户不应该到达主进程(对话框)是否可能?
答案 0 :(得分:2)
以下代码......
if( !CreateProcess( NULL, // No module name (use command line).
exePath, // Command line.
NULL,// Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
NORMAL_PRIORITY_CLASS,// No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
cout << "Unable to create\n";}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return false;
}
WaitForSingleObject( pi.hProcess, INFINITE );// wait user till close exe(after close child process then go parent process)
return true;
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
答案 1 :(得分:0)
可以使用OLE-Automation / COM轻松完成。使用进程外服务器,您有一个procdeual接口和第二个进程...