问个比较急的问题,明天就要交差了!!! 200 我想捕获 WM_SYSCOMMAND 消息, 用全局钩子怎么实现啊.系统屏保启动前会发送这个消息,我想捕获它,然后禁止屏保!!希望能给出代码.谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 BOOL CMFPApp::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message==WM_SYSCOMMAND && pMsg->wParam==SC_SCREENSAVE)return true; return CWinApp::PreTranslateMessage(pMsg); } 如果只是想在你程序运行的时候暂时禁用屏幕保护的话,不用那么麻烦.系统提供了一系统的API帮助你直接管理屏幕保护和电源管理选项. #include <windows.h>HHOOK g_hMouse=NULL;HHOOK g_hKeyboard=NULL;#pragma data_seg("MySec")HWND g_hWnd=NULL;#pragma data_seg()//#pragma comment(linker,"/section:MySec,RWS")/*HINSTANCE g_hInst;BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to the DLL module DWORD fdwReason, // reason for calling function LPVOID lpvReserved // reserved){ g_hInst=hinstDLL;}*/LRESULT CALLBACK MouseProc( int nCode, // hook code WPARAM wParam, // message identifier LPARAM lParam // mouse coordinates){ return 1;}LRESULT CALLBACK KeyboardProc( int code, // hook code WPARAM wParam, // virtual-key code LPARAM lParam // keystroke-message information){ if(VK_F2==wParam) { SendMessage(g_hWnd,WM_CLOSE,0,0); UnhookWindowsHookEx(g_hMouse); UnhookWindowsHookEx(g_hKeyboard); } return 1;}void SetHook(HWND hwnd){ g_hWnd=hwnd; g_hMouse=SetWindowsHookEx(WH_MOUSE,MouseProc,GetModuleHandle("Hook"),0); g_hKeyboard=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,GetModuleHandle("Hook"),0);} http://topic.csdn.net/t/20020204/17/518669.html 有个小问题请教大家。 急聘图形图像处理的程序员 付酬,关于IP地址欺骗的问题,高手请进 奇怪的二维数组 如何将十进制的数转换为二进制并显示在EDIT内?(谢谢) 关于MFC框架的一点理解和疑问。 DestroyWindow出错 linux挺好的 vc中钩子到底是什么意思?怎么解释?请高手对菜鸟的这疑惑进行一下解答! 请问怎样获得或执行文件的版本? 加载3ds文件 如何取得对话框的返回值?(在线等,实在没分啦~)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_SYSCOMMAND && pMsg->wParam==SC_SCREENSAVE)return true;
return CWinApp::PreTranslateMessage(pMsg);
}
系统提供了一系统的API帮助你直接管理屏幕保护和电源管理选项.
HHOOK g_hKeyboard=NULL;#pragma data_seg("MySec")
HWND g_hWnd=NULL;
#pragma data_seg()//#pragma comment(linker,"/section:MySec,RWS")
/*HINSTANCE g_hInst;BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to the DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved // reserved
)
{
g_hInst=hinstDLL;
}*/LRESULT CALLBACK MouseProc(
int nCode, // hook code
WPARAM wParam, // message identifier
LPARAM lParam // mouse coordinates
)
{
return 1;
}LRESULT CALLBACK KeyboardProc(
int code, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{
if(VK_F2==wParam)
{
SendMessage(g_hWnd,WM_CLOSE,0,0);
UnhookWindowsHookEx(g_hMouse);
UnhookWindowsHookEx(g_hKeyboard);
}
return 1;
}void SetHook(HWND hwnd)
{
g_hWnd=hwnd;
g_hMouse=SetWindowsHookEx(WH_MOUSE,MouseProc,GetModuleHandle("Hook"),0);
g_hKeyboard=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,GetModuleHandle("Hook"),0);
}