主题:[讨论]求救
#include <windows.h>老师好求求大家看看
HHOOK g_hMouse=NULL;
HHOOK g_hkeyboard=NULL;
HWND g_hWnd;
HHOOK g_hJournalRecordProc=NULL;
/*HINSTANCE g_hInst;
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved // reserved
)
{
g_hInst=hinstDLL;
}*/
LRESULT CALLBACK MouseProc(
int nCode, // hook code
WPARAM wParam, // message identifier
LPARAM lParam // mouse coordinates
)
{
return 1;
}
LRESULT CALLBACK KeyboardProc(
int code, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{
if(VK_F2==wParam)
{
SendMessage(g_hWnd,WM_CLOSE,0,0);
UnhookWindowsHookEx(g_hMouse);
UnhookWindowsHookEx(g_hkeyboard);
}
return 1;
}
LRESULT CALLBACK JournalRecordProc(
int code, // hook code
WPARAM wParam, // undefined
LPARAM lParam // address of message being processed
)
{
return 1;
}
void SetHook(HWND hwnd)
{
g_hWnd=hwnd;
g_hMouse=SetWindowsHookEx(WH_MOUSE,MouseProc,GetModuleHandle("Hook"),0);
g_hkeyboard=SetWindowsHookEx(WH_KEYBOARD,keyboardProc,GetModuleHandle("Hook"),0);
g_hJournalRecord=SetWindowsHookEx(WH_JOURNALRECORD,JournalRecordProc,GetModuleHandle("Hook"),0);
}这个代码出现以下问题为什么
-------------------Configuration: Hook - Win32 Debug--------------------
Compiling...
Hook.cpp
D:\CHENGXU\新建文件夹1\Hook\Hook.cpp(50) : error C2065: 'keyboardProc' : undeclared identifier
D:\CHENGXU\新建文件夹1\Hook\Hook.cpp(51) : error C2065: 'g_hJournalRecord' : undeclared identifier
D:\CHENGXU\新建文件夹1\Hook\Hook.cpp(51) : error C2440: '=' : cannot convert from 'struct HHOOK__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.
Hook.exe - 1 error(s), 0 warning(s)
HHOOK g_hMouse=NULL;
HHOOK g_hkeyboard=NULL;
HWND g_hWnd;
HHOOK g_hJournalRecordProc=NULL;
/*HINSTANCE g_hInst;
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved // reserved
)
{
g_hInst=hinstDLL;
}*/
LRESULT CALLBACK MouseProc(
int nCode, // hook code
WPARAM wParam, // message identifier
LPARAM lParam // mouse coordinates
)
{
return 1;
}
LRESULT CALLBACK KeyboardProc(
int code, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{
if(VK_F2==wParam)
{
SendMessage(g_hWnd,WM_CLOSE,0,0);
UnhookWindowsHookEx(g_hMouse);
UnhookWindowsHookEx(g_hkeyboard);
}
return 1;
}
LRESULT CALLBACK JournalRecordProc(
int code, // hook code
WPARAM wParam, // undefined
LPARAM lParam // address of message being processed
)
{
return 1;
}
void SetHook(HWND hwnd)
{
g_hWnd=hwnd;
g_hMouse=SetWindowsHookEx(WH_MOUSE,MouseProc,GetModuleHandle("Hook"),0);
g_hkeyboard=SetWindowsHookEx(WH_KEYBOARD,keyboardProc,GetModuleHandle("Hook"),0);
g_hJournalRecord=SetWindowsHookEx(WH_JOURNALRECORD,JournalRecordProc,GetModuleHandle("Hook"),0);
}这个代码出现以下问题为什么
-------------------Configuration: Hook - Win32 Debug--------------------
Compiling...
Hook.cpp
D:\CHENGXU\新建文件夹1\Hook\Hook.cpp(50) : error C2065: 'keyboardProc' : undeclared identifier
D:\CHENGXU\新建文件夹1\Hook\Hook.cpp(51) : error C2065: 'g_hJournalRecord' : undeclared identifier
D:\CHENGXU\新建文件夹1\Hook\Hook.cpp(51) : error C2440: '=' : cannot convert from 'struct HHOOK__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.
Hook.exe - 1 error(s), 0 warning(s)