@L_404_1@
1楼 该程序使用SetWindowsHookEx设置WH_CBT钩子以截取窗口创建,销毁等消息,MsgBox也不怕 核心代码 Public Function Hook_Func(ByVal iCode As Long,ByVal wParam As Long,ByVal lParam As Long) As Long Select Case iCode Case HCBT_CREATEWND Case HCBT_DESTROYWND Case HCBT_ACTIVATE Dim WinText As String Dim ClsName As String '获取窗口标题及类名 WinText = GetWindowTextString(wParam) ClsName = GetGetClassNameString(wParam) Debug.Print ClsName,GetWindowTextString(wParam) 'VB的弹窗类名 If ClsName = "#32770" Then '发送关闭消息 PostMessage wParam,WM_CLOSE,0 End If End Select Hook_Func = CallNextHookEx(hHook,iCode,wParam,lParam) End Function |