Listen to the beginning and end of the process

I am new to Windows API programming. I know that there are ways to check if a process is running (via enumeration). However, I was wondering if there is a way to listen when a process starts and ends (for example, notepad.exe), and then performs some actions when it detects the beginning or end of this process. I suppose it would be possible to start a continuous cycle of enumeration and verification for each limit unit of time, but I was wondering if there was a cleaner solution.

+5
source share
5 answers

Use the WMI, Win32_ProcessStartTrace, and Win32_ProcessStopTrace classes. C # code example here .

++. , erm, . , .

+4

- , "", - "WaitForMultipleObjects".

- , , MsgWaitForMultipleObjects(), .

0
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
\Image File Execution Options

, REG_SZ "" , .

, aproach, , .

0

Hans Passant, , , ... C ++.

Windows Vista, 95% - Windows WH_CBT, SetWindowsHookEx.

:

  • / , , . procs , explorer.exe / . Christian Steiber procs .

  • , . , # 1.

  • , hook, . , , .

- .

For Windows 7 and above, view SetWinEventHook. I have not written code to cover Win7, so I have no comments.

0
source

All Articles