莫名其妙的丢失 分号 ‘;’??
#include <afxwin.h>// #include <windows.h>
class CKeybHookApp : public CWinApp
{
public:
CKeybHookApp();
DECLARE_MESSAGE_MAP()
} theApp;
LRESULT CALLBACK LaunchHook(int nCode,WPARAM wParam,LPARAM lParam);
HHOOK kbHook;
// #define pCW ((CWPSTRUCT*)lParam)
LRESULT CALLBACK LaunchHook(int nCode,WPARAM wParam,LPARAM lParam)
{
// 让其它全局钩子获得消息.
LRESULT Result=CallNextHookEx(kbHook,nCode,wParam,lParam);
if(nCode==HC_ACTION)
{
LPCTSTR info = NULL;
if( (lParam & WM_KEYDOWN) == WM_KEYDOWN)
{
info = "key dn";
}
else if( (lParam & WM_KEYUP) == WM_KEYUP)
{
info = "key up";
}
else if( (lParam & WM_SYSKEYDOWN) == WM_SYSKEYDOWN)
{
info = "sys key down";
}
else ( (lParam & WM_SYSKEYUP) == WM_SYSKEYUP )
{ // 40 行???
info = "sys key up";
}
MessageBox(NULL,info,"win",MB_OK);
}
return Result;
}
int main (void)
{
kbHook=(HHOOK)SetWindowsHookEx(WH_KEYBOARD,
(HOOKPROC)LaunchHook, theApp.m_hInstance, 0 );
if( kbHook==NULL ) {
MessageBox(NULL,"error SetWindowsHookEx","win",MB_OK);
return 0;
}
// 消息循环是必须的,想知道原因可以查msdn
MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
};
UnhookWindowsHookEx (kbHook);
return 0;
};
为什么这个程序提示:
dd1.cpp(40) : error C2143: syntax error : missing ';' before '{'
感觉花括号已经匹配了啊??