如何获取shellexecute函数调用的exe的返回值。
ShellExecute(NULL, NULL, TEXT ( ".\\dpinstx86.exe" ), NULL, NULL, SW_SHOWNORMAL);
在上面的例子中,我想要“dpinstx86.exe”的返回值。
最佳答案
使用 ShellExecuteEx
而是获取进程句柄和 GetExitCodeProcess
获取退出代码。
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "c:\\MyProgram.exe";
ShExecInfo.lpParameters = "";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
关于c++ - 如何获取 ShellExecute 调用的 exe 的返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10896778/