16,473
社区成员
发帖
与我相关
我的任务
分享
LRESULT CALLBACK GetMsgProc( int nCode,
WPARAM wParam,
LPARAM lParam
)
{
if (nCode < 0 || nCode == HC_NOREMOVE)
return CallNextHookEx(hMsgHook,nCode,wParam,lParam);
PMSG pMsg = (PMSG) lParam;
if(pMsg->message == WM_SYSCOMMAND && pMsg->wParam == SC_MINIMIZE)
{
MessageBox(NULL,"GetMsg 截获","截获",0);
pMsg->message = NULL;
}
else if(pMsg->message == WM_NCLBUTTONDOWN && pMsg->wParam ==HTMINBUTTON)
{
MessageBox(NULL,"GetMsg 截获","截获",0);
pMsg->message = NULL;
}
return CallNextHookEx(hMsgHook,nCode,wParam,lParam);
}
MSG *Msg = (MSG*)lParam;
if(Msg->message == WM_SYSCOMMAND)
{
if(Msg->wParam == SC_MINIMIZE)
{
Msg.message = WM_NULL;
}
}
PMSG pMsg = (PMSG) lParam;
if(pMsg->message == WM_SYSCOMMAND && pMsg->wParam == SC_MINIMIZE)
{
MessageBox(NULL,"GetMsg 截获","截获",0);
pMsg->message = NULL; //改变消息
}
return CallNextHookEx(hMsgHook,code,wParam,lParam);
--------------------Configuration: HookDll - Win32 Debug--------------------
Compiling...
HookDll.cpp
D:\developer\projects\Test\HookDll\HookDll.cpp(31) : error C2440: 'type cast' : cannot convert from 'long' to 'struct tagCWPSTRUCT'
No constructor could take the source type, or constructor overload resolution was ambiguous
D:\developer\projects\Test\HookDll\HookDll.cpp(31) : error C2227: left of '->message' must point to class/struct/union
D:\developer\projects\Test\HookDll\HookDll.cpp(33) : error C2440: 'type cast' : cannot convert from 'long' to 'struct tagCWPSTRUCT'
No constructor could take the source type, or constructor overload resolution was ambiguous
D:\developer\projects\Test\HookDll\HookDll.cpp(33) : error C2227: left of '->wParam' must point to class/struct/union
Error executing cl.exe.
HookDll.dll - 4 error(s), 0 warning(s)
LRESULT WINAPI CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode < 0 || nCode == HC_NOREMOVE)
return CallNextHookEx(g_hCallWndHook,nCode,wParam,lParam);
if (((CWPSTRUCT)lParam)->message==WM_SYSCOMMAND)
{
if (((CWPSTRUCT)lParam)->wParam==SC_MINIMIZE)
{
MessageBeep(0);
}
}
return CallNextHookEx(g_hCallWndHook,nCode,wParam,lParam);
}
LRESULT CALLBACK GetMsgProc(
int code,
WPARAM wParam,
LPARAM lParam)
{
/*if(SC_MINIMIZE==HIWORD(wParam))
{
::MessageBox(g_hWnd,"ÆË×½µ½SC_MINIMIZE!",NULL,0);
return 1;
}
else
return CallNextHookEx(g_hMsg,code,wParam,lParam);*/
//return 1;
PMSG pmsg=(PMSG)lParam;
if(WM_SYSCOMMAND==pmsg->message && pmsg->wParam==SC_MINIMIZE)
{
HWND hwnd=GetForegroundWindow();
::MessageBox(hwnd,"Catch SC_MINIMIZE",NULL,0);
return 1;
}
return CallNextHookEx(g_hMsg,code,wParam,lParam);
}