title: SetWindowsHookEx for WH_MOUSE
body: <p>I've got some code into my hands that prints coordinates of the mouse globally (using WH_MOUSE_LL). My target is to use WH_MOUSE instead of WH_MOUSE_LL because (from what I've read) it is faster. I've read over the forum that when using WH_MOUSE it needs to be declared in DLL to achieve global effect, but still, when used in the program it should work over that application where it was declared, but it doesn't work (it prints nothing) when I just change the WH_MOUSE_LL to WH_MOUSE. This is the code:</p>
  
  <pre><code>#define _WIN32_WINNT 0x0400
  #pragma comment( lib, "user32.lib" )
  
  #include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  
  HHOOK hMouseHook;
  
  LRESULT CALLBACK mouseProc (int nCode, WPARAM wParam, LPARAM lParam)
  {
      MOUSEHOOKSTRUCT * pMouseStruct = (MOUSEHOOKSTRUCT *)lParam;
      if (pMouseStruct != NULL){
          if(wParam == WM_LBUTTONDOWN)
          {
              printf( "clicked" ); 
          }
          printf("Mouse position X = %d  Mouse Position Y = %d\n", pMouseStruct-&gt;pt.x,pMouseStruct-&gt;pt.y);
      }
      return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
  }
  
  DWORD WINAPI MyMouseLogger(LPVOID lpParm)
  {
      HINSTANCE hInstance = GetModuleHandle(NULL);
  
      // here I put WH_MOUSE instead of WH_MOUSE_LL
      hMouseHook = SetWindowsHookEx( WH_MOUSE_LL, mouseProc, hInstance, NULL );
  
      MSG message;
      while (GetMessage(&amp;message,NULL,0,0)) {
          TranslateMessage( &amp;message );
          DispatchMessage( &amp;message );
      }
  
      UnhookWindowsHookEx(hMouseHook);
      return 0;
  }
  
  int main(int argc, char** argv)
  {
      HANDLE hThread;
      DWORD dwThread;
  
      hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)MyMouseLogger, (LPVOID) argv[0], NULL, &amp;dwThread);
      if (hThread)
          return WaitForSingleObject(hThread,INFINITE);
      else
          return 1;
  
  }
  </code></pre>