how to get return value of an exe called by ShellExecute
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);