Posts

Showing posts with the label HookManager

can not add (global) event handler - The specified module could not be found - Error Code : 126

Hello, I want to add KeyPress Event to my program ;               this.globalEventProvider1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.globalEventProvider1_MouseDown);             this.globalEventProvider1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.globalEventProvider1_MouseUp); when i execute them, I am facing error; System.ComponentModel.Win32Exception: 'The specified module could not be found' Solution : We should load user32.dll and make a call as seen below: Load user32.dll and user it in SetWindowHookEx  //See comment of this field. To avoid GC to clean it up.                 s_MouseDelegate = MouseHookProc;                 var mar = LoadLibrary("user32.dll");                 //install hook                 s_MouseHookHandle = SetWindowsHookEx(                     WH_MOUSE_LL,                     s_MouseDelegate,                     /* Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]),