C++, How to determine if a Windows Process is running?

前端 未结 13 1138
清酒与你
清酒与你 2020-11-27 15:27

This is concerning Windows XP processes.

I have a process running, let\'s call it Process1. Process1 creates a new process, Process2, and saves its id.

Now,

13条回答
  •  独厮守ぢ
    2020-11-27 16:03

    You can never check and see if a process is running, you can only check to see if a process was running at some point in the recent past. A process is an entity that is not controlled by your application and can exit at any moment in time. There is no way to guaranteed that a process will not exit in between the check to see if it's running and the corresponding action.

    The best approach is to just do the action required and catch the exception that would be thrown if the process was not running.

提交回复
热议问题