vb6 怎么关闭自己调用shell启动的程序
若以下回答无法解决问题,邀请你更新回答
展开全部
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredaccess&, ByVal bInherithandle&, ByVal dwProcessid&) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Dim mHwnd As Long
Public Function killPID(ByVal PID As Long) As Boolean
Dim lProcess As Long, ret As Long
lProcess = OpenProcess(&H1F0FFF, False, PID)
ret = TerminateProcess(lProcess, 0&)
If ret <> 0 Then
killPID = True
End If
CloseHandle lProcess
End Function
Private Sub Command1_Click()
If killPID(mHwnd) Then
MsgBox "成功关闭 PID = " & mHwnd & " 的进程。"
End If
End Sub
Private Sub Form_Load()
mHwnd = Shell("notepad.exe", vbNormalFocus)
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询