Hi, i want to do system hook WH_SYSMSGFILTER,
my code is:
IntPtr hMod =
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly ().GetModules()[0]);
//install hook
hSysMsgHook = Api.User32.SetWindowsHookEx(WH_SYSMSGFILTER,
SysMsgHookProcedure, hMod, 0);
//If SetWindowsHookex fails.
if (hSysMsgHook == 0)
{
int errorCode = Marshal.GetLastWin32Error();
//do cleanup
Stop(false, false, true, false);
//Initializes and throws a new instance of the Win32Exception class with
the specified error.
throw new Win32Exception(errorCode);
}
hMod is valid but the api return code is ERROR_HOOK_NEEDS_HMOD!
other types of hook like WH_KEYBOARD_LL or WH_MOUSE_LL works fine!
my machine is windows vista
what's wrong?
Thanks