Why those two different behaviors with WaitForSingleObject function in CPP

前端 未结 2 1797
别那么骄傲
别那么骄傲 2021-01-23 01:57

I have the following code sample:

#include 
#include 
#include 

using namespace std;

void main()
{
    SHELLEXEC         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 02:34

    I tried your code on Windows 10, and SysInternals Process Monitor shows the following:

    As you can see, calc.exe spawns a new process and then ends, thus satisfying the wait. That is why you see your output immediately. This second process is the actual calculator process. In my case, it is located at this path:

    C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1612.3341.0_x64__8wekyb3d8bbwe\Calculator.exe
    

提交回复
热议问题