调试一个vc钩子程序时遇到的问题
关于安装日志钩子
//g_hLogHook是全局变量
app->g_hLogHook = SetWindowsHookEx(WH_JOURNALRECORD,
JournalLogProc,HInstance,0);
HOOKPROC JournalLogProc(int iCode, WPARAM wParam, LPARAM lParam)
{
......
}
error C2664: 'SetWindowsHookExA' : cannot convert parameter 2 from
'long (__stdcall *(int,unsigned int,long))(int,unsigned int,long)' to
'long (__stdcall *)(int,unsigned int,long)'
None of the functions with this name in scope match the target type
关于文件调用
我在程序里调用了两处GetTime()函数,一处调用成功,另一处报错。
CString szTime;
szTime=GetTime();
CString CKeyBoardDlg::GetTime()
{
CTime oTime;
int year,month,day,hour,minute,second;
oTime=CTime::GetCurrentTime();
year=oTime.GetYear();
month=oTime.GetMonth();
day=oTime.GetDay();
hour=oTime.GetHour();
minute=oTime.GetMinute();
second=oTime.GetSecond();
//设置时间的格式
CString strTime;
strTime.Format("%d/%d/%d %d:%d:%d",year,month,day,hour,minute,second);
return strTime;
}
error C2065: 'GetTime' : undeclared identifier
关于MSGEVENT结构
成功安装日志钩子,钩子回调函数HOOKPROC JournalLogProc(int iCode, WPARAM wParam, LPARAM lParam)
如果参数iCode值为HC_ACTION,参数lParam应是EVENTMSG指针,我用了如下代码:
if (iCode==HC_ACTION)
{
EVENTMSG *pEvt;
pEvt=(EVENTMSG *)lParam;
}
系统报错:error C2065: 'pEvt' : undeclared identifier
初学VC,这些问题该如何解决,还请大家多多指点