HOOK格式化提示框
请问在vc环境下用钩子函数(HOOK)如何勾住“磁盘未格式化”提示框?
提示:千万不要跟我说是我的卡坏了,不然我会抓狂的!只要回答问题就可以了!
[解决办法]
SetWindowsHookEx(WH_CALLWNDPROC , (HOOKPROC)CallWndProc , g_hModDll, dwThreadID );
LRESULT CALLBACK CallWndProc( int nCode, // hook code
WPARAM wParam, // depends on hook code
LPARAM lParam // depends on hook code
)
{
if( 0 > nCode )
return CallNextHookEx( g_hHk_WNDPROC, nCode, wParam, lParam );
if ( HC_ACTION == nCode )
{
CWPSTRUCT* lpCWPSTRUCT=(CWPSTRUCT*)lParam;
HWND hWnd = lpCWPSTRUCT->hwnd;
char szWindowName[512] = { 0 };
::GetWindowText( hWnd, szWindowName, 512 );
switch ( lpCWPSTRUCT->message )
{
case WM_CREATE:
{
// 判断子窗口的字符串
SendMessage( hWnd, WM_CLOSE, NULL, NULL );
break;
}
default:
break;
}
}
return CallNextHookEx( g_hHk_WNDPROC , nCode , wParam , lParam );
}