VB中 如何判断程序是否在运行??
VB中如何判断程序是否在运行??点击COMMAND1运行程序!在点击时判断程序是否在运行如果是的话弹出提示框!麻烦写下代码!...
VB中如何判断程序是否在运行??
点击 COMMAND1
运行程序!
在点击时
判断 程序是否在运行
如果是的话 弹出提示框!
麻烦写下代码! 展开
点击 COMMAND1
运行程序!
在点击时
判断 程序是否在运行
如果是的话 弹出提示框!
麻烦写下代码! 展开
1个回答
展开全部
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByRef lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Const PROCESS_QUERY_INFORMATION As Long = (&H400)
Private Const STILL_ACTIVE As Long = &H103
Public hShell As Long, hProc As Long, lExit As Long
Private Sub Command1_Click()
hProc = OpenProcess(PROCESS_QUERY_INFORMATION, False, hShell)
GetExitCodeProcess hProc, lExit
If lExit = STILL_ACTIVE Then
MsgBox "程序正在运行"
Else
hShell = Shell("cmd.exe")
End If
End Sub
Private Declare Function GetExitCodeProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByRef lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Const PROCESS_QUERY_INFORMATION As Long = (&H400)
Private Const STILL_ACTIVE As Long = &H103
Public hShell As Long, hProc As Long, lExit As Long
Private Sub Command1_Click()
hProc = OpenProcess(PROCESS_QUERY_INFORMATION, False, hShell)
GetExitCodeProcess hProc, lExit
If lExit = STILL_ACTIVE Then
MsgBox "程序正在运行"
Else
hShell = Shell("cmd.exe")
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询