how to get return value of an exe called by ShellExecute

前端 未结 1 408
说谎
说谎 2020-12-13 11:16

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

ShellExecute(NULL, NULL, TEXT ( \".\\\\dpinstx86.exe\" ), NULL, NULL, SW_SHOW         


        
相关标签:
1条回答
  • 2020-12-13 11:25

    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);
    
    0 讨论(0)
提交回复
热议问题