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.
Use the WMI, Win32_ProcessStartTrace, and Win32_ProcessStopTrace classes. C # code example here .
++. , erm, . , .
, Windows NT/2K.
- , "", - "WaitForMultipleObjects".
- , , MsgWaitForMultipleObjects(), .
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion \Image File Execution Options
, REG_SZ "" , .
, aproach, , .
Hans Passant, , , ... C ++.
Windows Vista, 95% - Windows WH_CBT, SetWindowsHookEx.
WH_CBT
SetWindowsHookEx
:
/ , , . procs , explorer.exe / . Christian Steiber procs .
, . , # 1.
- .
For Windows 7 and above, view SetWinEventHook. I have not written code to cover Win7, so I have no comments.
SetWinEventHook