vb 关于HOOK阻止弹出MsgBox窗口,

 
  • vb 关于HOOK阻止弹出MsgBox窗口,_第1张图片
  • lionking1990
  • 前来围观
    7

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, 0
         End If
     End Select
    
     Hook_Func = CallNextHookEx(hHook, iCode, wParam, lParam)
End Function

你可能感兴趣的:(function,String,vb,hook)