Exemple #1
0
 private void EnsureSubscribedToGlobalMouseEvents()
 {
     if (_sMouseHookHandle == 0)
     {
         _sMouseDelegate = MouseHookProc;
         var executingAssembly = Assembly.GetExecutingAssembly();
         // ReSharper disable once UnusedVariable
         var module = executingAssembly.GetModules()[0];
         var intPtr =
             Win32Interop.GetModuleHandle(Process.GetCurrentProcess().MainModule
                                          .ModuleName); //Marshal.GetHINSTANCE(module);
         _sMouseHookHandle = Win32Interop.SetWindowsHookEx(14, _sMouseDelegate, intPtr, 0);
         if (_sMouseHookHandle == 0)
         {
             throw new Win32Exception(Marshal.GetLastWin32Error());
         }
     }
 }