用VC建立一个动态库(DLL),在动态库中通过使用SetWindowsHookEx函数设置鼠标消息钩子,在钩子回调函数中判断鼠标按键。HHOOK SetWindowsHookEx(
  int idHook,        // type of hook to install
  HOOKPROC lpfn,     // address of hook procedure
  HINSTANCE hMod,    // handle to application instance
  DWORD dwThreadId   // identity of thread to install hook for
);LRESULT CALLBACK MouseProc(
  int nCode,      // hook code
  WPARAM wParam,  // message identifier
  LPARAM lParam   // mouse coordinates
);
  HHOOK hMouseHook=SetWindowsHookEx(WH_MOUSE , MouseProc , hInstance , 0 /*所有线程的鼠标消息*/);