[DllImport("user32.dll")]
static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr
hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess,
uint idThread, uint dwFlags);
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
Please add some!
Please add some!
The ManagedWindowsApi project (http://mwinapi.sourceforge.net) provides a SystemAccessibleObject class to access accessible objects and handle accessible events.