[This is preliminary documentation and subject to change.]
Sets an event hook for a range of events.
HWINEVENTHOOK WINAPI SetWinEventHook(
UINT eventMin,
UINT eventMax,
HMODULE hmodWinEventProc,
WINEVENTPROC lpfnWinEventProc,
DWORD idProcess,
DWORD idThread,
UINT dwflags
);
WINEVENT_INCONTEXT | |
USER sends event notifications to the callback function as they occur. In this case, the DLL containing the callback function is mapped into the address space of the process generating the event. The callback function must be in a DLL to use this option. | |
WINEVENT_OUTOFCONTEXT | |
USER sends event notifications that are queued before sending them to the callback function. Queuing is required because the callback function is not mapped into the address space of the process generating the event. Although this method is asynchronous, events are guaranteed to be in sequential order. | |
WINEVENT_SKIPOWNPROCESS | |
Prevents any threads in the caller's process from receiving their own notifications. This flag does not prevent threads from generating events. | |
WINEVENT_SKIPOWNTHREAD | |
Prevents the thread that is processing notifications from receiving any events it might have generated itself. This flag does not prevent the thread from generating events. |
Returns an HWINEVENTHOOK value that identifies this event hook instance if successful, or zero otherwise. Your application should save this return value to use with the UnhookWinEvent function.
This function allows you to specify not only which events you want, but also the process and thread in which you want to look for those events. This is useful when you want to work only with certain applications or just the system.
If the idProcess parameter is nonzero and idThread is zero, this function will hook all threads in that process. If the idProcess parameter is zero and idThread is nonzero, this function will hook only the thread specified by idThread. If both are zero, the function will hook in all threads and processes.
To monitor a noncontiguous range of events, call this method twice, specifying the same callback function in the lpfnWinEventProc parameter each time.
The client thread calling SetWinEventHook must be a thread that has a message loop, sometimes known as a "GUI thread."
About the WinEventProc Callback Function.