如何獲取由shellexecute函數調用的exe的返回值。如何獲取由ShellExecute調用的exe的返回值
ShellExecute(NULL, NULL, TEXT (".\\dpinstx86.exe"), NULL, NULL, SW_SHOWNORMAL);
在上面的例子中,我想要「dpinstx86.exe」的返回值。
如何獲取由shellexecute函數調用的exe的返回值。如何獲取由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);
我覺得你「返回值」的意思是從CMD的輸出,這個問題地址:http://stackoverflow.com/questions/469152/using-shellexecuteex-and-capturing-standard-in退房手續,ERR。 – Ben