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, 0, 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
用vb代开关闭exe文件
最新推荐文章于 2014-10-09 20:53:18 发布