sinat_17144053
2015-06-05 03:00
采纳率: 71.4%
浏览 2.6k
已采纳

新手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 2015-06-05 03:12
    已采纳

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

    点赞 打赏 评论
  • 91program 2015-06-05 03:03

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

    点赞 打赏 评论
  • wd0033 2015-06-05 03:20

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

    点赞 打赏 评论

相关推荐 更多相似问题