Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_CLOSE = &H10
Private Sub Command1_Click()
If Text1.Text = vbNullString Then
MsgBox "请输入要禁止运行的程序窗口标题!": Text1.SetFocus: Exit Sub
Else
Timer1.Enabled = True: MsgBox "设置生效!": Me.Visible = False
End If
End Sub
Private Sub Form_Load()
App.TaskVisible = False
End Sub
Private Sub Timer1_Timer()
Dim MyWinHwnd As Long
MyWinHwnd = FindWindow(vbNullSting, Text1.Text)
If MyWinHwnd <> 0 Then
SendMessage MyWinHwnd, WM_CLOSE, 0, 0
End If
End Sub