c++ - 如何获取 ShellExecute 调用的 exe 的返回值

标签 c++ c api winapi shellexecute

如何获取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/

相关文章:

c++ - 每个顶点加权法线请记住OpenGL C++中的折角

c++ - 我应该如何在不同的操作系统上测试独立的应用程序

c++ - 混合 C 和 C++ 时不断出现 LNK2019 错误

c - 2 种排序方法的意外结果 C

node.js - Alexa Nodejs设备地址api

api - 在 Google Charts API 中,如何获取 DataTable 中单元格的值?

api - Salesforce WebServiceCallout.invoke 方法的参数是什么?

c++ - 使用 Divide and Conquer 在 char 数组中搜索字符串

c++ - 如何将负整数传递给 COM/OLE 函数?

c - 免费 GSL 矩阵的正确方法是什么?