Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long,ByVal uExitCode As Long) As Long Private Declare Function OpenProcess Lib "kernel32" _ (ByVal dwDesiredAccess As Long,ByVal bInheritHandle As Long,_ ByVal dwProcessID As Long) As Long Private Const PROCESS_TERMINATE = &H1 Private hProcess As Long Private Sub Command1_Click() Dim pid As Long pid = Shell("F:\webServer\mongoose-3.7.exe",vbnormalFocus) If pid = 0 Then MsgBox "没有打开程序" Else hProcess = OpenProcess(PROCESS_TERMINATE,pid) End If End Sub Private Sub Command2_Click() Dim l As Long l = TerminateProcess(hProcess,1) If l <> 0 Then MsgBox "成功关闭" Else MsgBox "未关闭" End If End Sub