以下是我编写的代码,我验证其截获了ID,但不能记录文本,不只为何?请指教~~~~
钩子类型WH_CALLWNDPROC
LRESULT CALLBACK LauncherHook3( int nCode,WPARAM wParam,LPARAM lParam)
{LPCWPSTRUCT lpmsg=(LPCWPSTRUCT)lParam;//获取消息结构
if (nCode==HC_ACTION && !wParam) //判断是否为菜单消息
{
if (lpmsg->message==WM_COMMAND)
{
CString s;
char stxt[100];
HMENU hMenu=GetMenu(lpmsg->hwnd);//获取主菜单句柄
GetMenuString(hMenu,LOWORD(lpmsg->wParam),stxt,100,MF_BYCOMMAND);//获取菜单文本
s=stxt;
SaveLog2(s);记录,函数另写
return CallNextHookEx(Hook,nCode,wParam,lParam) ;
}
return CallNextHookEx(Hook ,nCode ,wParam ,lParam) ;
}
else
{
return CallNextHookEx(Hook ,nCode ,wParam ,lParam) ;
}
}