SetWindowsHookEx échoue avec l’erreur 1428

J’essaie de connecter le bouton de démarrage avec le code suivant.

// Create an instance of HookProc. StartHookProcedure = new CallBack(StartHookProc); IntPtr desktop = FindWindowEx( IntPtr.Zero, IntPtr.Zero, "Progman", null); uint procId = 0; uint threadId = GetWindowThreadProcessId(desktop, out procId); Process process = Process.GetCurrentProcess(); ProcessModule module = process.MainModule; IntPtr hModule = GetModuleHandle(null); // get my module handle... //IntPtr start = FindWindowEx(desktop, IntPtr.Zero, "Button", null); hHook = SetWindowsHookEx(WH_GETMESSAGE, StartHookProcedure, hModule, (int)threadId); //If the SetWindowsHookEx function fails. if (hHook == 0) { int err = Marshal.GetLastWin32Error(); MessageBox.Show("SetWindowsHookEx Failed" + err.ToSsortingng()); return; } 

SetWindowHookEx est toujours en erreur 1428 ERROR_HOOK_NEEDS_HMOD

Impossible de définir un crochet non local sans poignée de module.

Je ne peux pas comprendre cela. Il échoue bien que j’appelle GetModuleHandle(null) .