vb判断指定路径的exe是否正在运行
C:\svchost.exe肯定存在,请判断此exe是否正在运行!不要用判断进程是否正在运行的方法!!回答的对再加分我要代码,请尽快aa4681464,你的方法不行啊!是...
C:\svchost.exe 肯定存在,请判断此exe是否正在运行!
不要用判断进程是否正在运行的方法!!
回答的对再加分
我要代码,请尽快
aa4681464,你的方法不行啊! 是指定路径!!
mmx1122,判断其他EXE,不要误解!! 展开
不要用判断进程是否正在运行的方法!!
回答的对再加分
我要代码,请尽快
aa4681464,你的方法不行啊! 是指定路径!!
mmx1122,判断其他EXE,不要误解!! 展开
2个回答
展开全部
Private Declare Function CreateFile Lib "KERNEL32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As String, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "KERNEL32" (ByVal hObject As Long) As Long
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const OPEN_EXISTING = 3
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const INVALID_HANDLE_VALUE = -1
Private Function IsFileRun(ByVal pFile As String) As Boolean
Dim ret As Long
ret = CreateFile(pFile, GENERIC_READ Or GENERIC_WRITE, 0&, vbNullString, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0&)
IsFileRun = (ret = INVALID_HANDLE_VALUE)
CloseHandle ret
End Function
Private Sub Command1_Click()
Dim File As String
File = "G:\腾讯QQ\QQ.exe" '路径自己改吧
MsgBox File & IIf((Dir(File) <> "" And IsFileRun(File)), "已运行!", "未运行!")
End Sub
Private Declare Function CloseHandle Lib "KERNEL32" (ByVal hObject As Long) As Long
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const OPEN_EXISTING = 3
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const INVALID_HANDLE_VALUE = -1
Private Function IsFileRun(ByVal pFile As String) As Boolean
Dim ret As Long
ret = CreateFile(pFile, GENERIC_READ Or GENERIC_WRITE, 0&, vbNullString, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0&)
IsFileRun = (ret = INVALID_HANDLE_VALUE)
CloseHandle ret
End Function
Private Sub Command1_Click()
Dim File As String
File = "G:\腾讯QQ\QQ.exe" '路径自己改吧
MsgBox File & IIf((Dir(File) <> "" And IsFileRun(File)), "已运行!", "未运行!")
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询