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()
Dim hwd As Long
hwd = FindWindow(vbNullString, "Textpad") '把Textpad换为你要关闭程序的标题
SendMessage hwd, WM_CLOSE, 1, vbNullString
End Sub
Public Function KillApp(myName As String) As Boolean
On Error GoTo errorhandler
GoSub begin
errorhandler:
Exit Function
begin:
Dim uProcess As PROCESSENTRY32
Dim rProcessFound As Long
Dim hSnapShot As Long
Dim szExename As String
Dim exitCode As Long
Dim myProcess As Long
Dim AppKill As Boolean
Dim appCount As Integer
Dim i As Integer
Const PROCESS_ALL_ACCESS = 0
Const TH32CS_SNAPPROCESS As Long = 2&