|
Cannot convert 'type1' to 'type2' (E2034)
An assignment, initialization, or expression requires the specified type conversion to be performed, but the conversion is not legal.
In C++, the compiler will convert one function pointer to another only if the signature for the functions are the same. Signature refers to the arguments and return type of the function.
따라서 아래와 같이 해보면 될듯...
hKeyHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC),KeyHookProc, NULL, GetCurrentThreadId());
동철이 님이 쓰신 글 :
: 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)')
|