如何获取ShellExecute调用的exe的返回值 [英] how to get return value of an exe called by ShellExecute

查看:90
本文介绍了如何获取ShellExecute调用的exe的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取shellexecute函数调用的exe的返回值

How to get the return value of an exe which is called by shellexecute function.

ShellExecute(NULL, NULL, TEXT ( ".\\dpinstx86.exe" ), NULL, NULL, SW_SHOWNORMAL);

在上面的例子中,我想要dpinstx86.exe"的返回值.

In the above example I want the return value of "dpinstx86.exe".

推荐答案

使用 ShellExecuteEx 来获取进程句柄,GetExitCodeProcess 获取退出代码.

Use ShellExecuteEx instead to get the process handle, and GetExitCodeProcess to get the exit code.

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);

这篇关于如何获取ShellExecute调用的exe的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆