问题
Here Goes My Code
// hook.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam);
int _tmain(int argc, _TCHAR* argv[]){
int __;
cout << "Hallo World" << endl;
SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0, 0);
cin >> __;
return 0;
}
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam){
cout << code << endl;
return 0;
}
I am trying to get WM_PAINT event... at the moment I am trying to trap all the events. Where I am Missing ?
回答1:
Read the documentation please. It clearly states why your usage is incorrect especially with regard to the last two parameters. If you want to hook every thread you need to provide a module http://msdn.microsoft.com/en-us/library/ms644990(v=vs.85).aspx
来源:https://stackoverflow.com/questions/5432551/wm-paint-hook-using-setwindowshookex