|
LRESULT CALLBACK KeyHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
char str[MAX_PATH];
RECT rt = {100, 120, 500, 150};
static int Count = 0;
if(nCode < 0)
return CallNextHookEx(hKeyHook, nCode, wParam, lParam);
hdc = GetDC(hWndMain);
wsprintf(str, "nCode = %d, wParam = %u, lParam = %08x, Count = %d",
nCode, wParam, lParam, Count++);
FillRect(hdc, &rt, (HBRUSH)GetStockObject(WHITE_BRUSH));
TextOut(hdc, 100, 120, str, strlen(str));
ReleaseDC(hWndMain, hdc);
return CallNextHookEx(hKeyHook, nCode, wParam, lParam);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
char mes[] = "키보드 훅 테스트 프로그램이단다.";
switch(iMessage)
{
case WM_CREATE:
hKeyHook = SetWindowsHookEx(WH_KEYBOARD, KeyHookProc,, NULL, GetCurrentThreadId());
return 0;
다음은 에러메시지이고 위 빨간 파라메터에서 에러난게 분명한데요.
SetWindowsHookEx의 원형은 HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId);인데 왜 이런 에러가 나는지 모르겠습니다. 어떻게 바꿔야 할지...
[C++ Error] proc1.cpp(71): E2034 Cannot convert 'long (__stdcall *)(int,unsigned int,long)' to 'int (__stdcall *)()'
[C++ Error] proc1.cpp(71): E2342 Type mismatch in parameter 'lpfn' (wanted 'int (__stdcall *)()', got 'long (__stdcall *)(int,unsigned int,long)')
|