用vb代开关闭exe文件
发布时间:2020-12-17 08:18:36 所属栏目:百科 来源:网络整理
导读: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 dwP
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:webServermongoose-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
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
