如何获得通过的ShellExecute称为一个EXE的返回值 [英] how to get return value of an exe called by ShellExecute

查看:1518
本文介绍了如何获得通过的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 ,而不是获取进程句柄,的 GetExit codeProcess 获得出口code。

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天全站免登陆