2 sinat 17144053 sinat_17144053 于 2015.06.05 11:00 提问

新手MFC求助,关于error LNK2019的问题。

1>MFCApplication2Dlg.obj : error LNK2019: 无法解析的外部符号 "public: static long __stdcall CMFCApplication2Dlg::JournalRecordProc(int,unsigned int,long)" (?JournalRecordProc@CMFCApplication2Dlg@@SGJHIJ@Z),该符号在函数 "public: void __thiscall CMFCApplication2Dlg::OnBnClickedButton3(void)" (?OnBnClickedButton3@CMFCApplication2Dlg@@QAEXXZ) 中被引用
1>MFCApplication2Dlg.obj : error LNK2019: 无法解析的外部符号 "public: static long __stdcall CMFCApplication2Dlg::JounralPlaybackProc(int,unsigned int,long)" (?JounralPlaybackProc@CMFCApplication2Dlg@@SGJHIJ@Z),该符号在函数 "public: void __thiscall CMFCApplication2Dlg::OnBnClickedButton1(void)" (?OnBnClickedButton1@CMFCApplication2Dlg@@QAEXXZ) 中被引用
1>E:\PJB\MFCApplication2\Debug\MFCApplication2.exe : fatal error LNK1120: 2 个无法解析的外部命令
void CMFCApplication2Dlg::OnBnClickedButton3()
{
hHook =SetWindowsHookEx(
WH_JOURNALRECORD,
(HOOKPROC)JournalRecordProc,
AfxGetApp()->m_hInstance,
0
);

// TODO: 在此添加控件通知处理程序代码

}
void CMFCApplication2Dlg::OnBnClickedButton1()
{
hHook=SetWindowsHookEx(
WH_JOURNALPLAYBACK,
(HOOKPROC)JounralPlaybackProc,
AfxGetApp()->m_hInstance,
0
);
// TODO: 在此添加控件通知处理程序代码
}
static LRESULT CALLBACK JournalRecordProc(int nCode,WPARAM wparam,LPARAM lparam)
{
if (nCode<0)
return CallNextHookEx(NULL,nCode,wparam,lparam);
EVENTMSG*pmsg=(EVENTMSG*)lparam;
switch(nCode)
{
case HC_ACTION:
{EVENTMSG * pEventMsg =new EVENTMSG;
memcpy(pEventMsg,pmsg,sizeof(EVENTMSG));
EventMsgList.AddTail(pEventMsg);}
break;
case HC_SYSMODALOFF:
break;
case HC_SYSMODALON:
break;

}

}
static LRESULT CALLBACK JournalPlaybackProc(int nCode,WPARAM wparam,LPARAM lparam)
{
static unsigned i=0;
static BOOL bFlag =TRUE;
EVENTMSG*pMsg;
POSITION pos;
DWORD PreTime,NowTime;
switch (nCode)
{
case HC_SKIP:
bFlag =TRUE;
i++;
break;
case HC_GETNEXT:
if(i>=EventMsgList.GetCount()-2)
{
i=0;
UnhookWindowsHookEx(hHook);
AfxMessageBox(_T("回放完毕!"));
}
pos=EventMsgList.FindIndex(i);
pMsg=EventMsgList.GetAt(pos);
memcpy((LPEVENTMSG)lparam,pMsg,sizeof(EVENTMSG));
if((i)!=0 && bFlag==TRUE)
{
bFlag=FALSE;
NowTime=pMsg->time;
pos=EventMsgList.FindIndex(i-1);
pMsg=EventMsgList.GetAt(pos);
PreTime=pMsg->time;
return NowTime-PreTime;
}
else return 0;
break;
default:
return CallNextHookEx(NULL,nCode,wparam,lparam);
}
return 0;

}
请问下哪有错啊,很急

3个回答

yangbo50304
yangbo50304   2015.06.05 11:12
已采纳

cpp中定义错了修改下试试,把static删了也
LRESULT CALLBACK CMFCApplication2Dlg::JournalRecordProc(int nCode,WPARAM wparam,LPARAM lparam)
LRESULT CALLBACK CMFCApplication2Dlg::JournalPlaybackProc(int nCode,WPARAM wparam,LPARAM lparam)

sinat_17144053
sinat_17144053 回复sinat_17144053: 可以用了,谢谢,不过我这录制回放点了都没反应。。。。
2 年多之前 回复
sinat_17144053
sinat_17144053 然后出现了这个: error C2039: “JournalPlaybackProc”: 不是“CMFCApplication2Dlg”的成员。另一个倒是没提示有问题
2 年多之前 回复
91program
91program   Ds   Rxr 2015.06.05 11:03

调用在定义前,这种情况需要先声明函数

wd0033
wd0033   2015.06.05 11:20

在代码前面加上: static LRESULT CALLBACK JournalRecordProc(int nCode,WPARAM wparam,LPARAM lparam);
static LRESULT CALLBACK JournalPlaybackProc(int nCode,WPARAM wparam,LPARAM lparam);

sinat_17144053
sinat_17144053 是在CPP最上面加吗?加了还是这样啊
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片