SetWinEventHook (user32)
Last changed: -38.94.164.162

.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr
   hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess,
   uint idThread, uint dwFlags);

User-Defined Types:

WinEventDelegate

Notes:

The MSDN documentation states:

When you use a Win32 API that has a callback in managed code, such as SetWinEventHook, you should use GCHandle class structure to avoid exceptions.

This is apparently not accurate as the P/Invoke layer automatically generates a marshaling stub at a fixed address:

http://blogs.msdn.com/cbrumme/archive/2003/05/06/51385.aspx

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

The ManagedWindowsApi project (http://mwinapi.sourceforge.net) provides a SystemAccessibleObject class to access accessible objects and handle accessible events.

Documentation