Windows how to get the process group of a process that is already running?

前端 未结 2 1834
独厮守ぢ
独厮守ぢ 2020-12-21 08:24

I have a WPF application that starts a new process using Process.Start(ProcessStartInfo info).

How do I get the group process ID of the process so that

2条回答
  •  暖寄归人
    2020-12-21 08:47

    The documentation for GenerateConsoleCtrlEvent states (emphasis mine):

    The identifier of the process group to receive the signal. A process group is created when the CREATE_NEW_PROCESS_GROUP flag is specified in a call to the CreateProcess function. The process identifier of the new process is also the process group identifier of a new process group.

    So if your processes are in a group, the WPF application's PID should be the group ID.

提交回复
热议问题