Hi
Option Explicit
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, uProcess As Any) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, uProcess As Any) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, th32ProcessID As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Function Running(ByVal sFileName As String) As Boolean
Dim hSnapshot As Long
Dim s As String * 1024
Dim b(1059) As Byte
CopyMemory b(0), 1060&, 4
hSnapshot = CreateToolhelp32Snapshot(2, 0)
Process32First hSnapshot, b(0) 'bpe32
Do While Process32Next(hSnapshot, b(0)) <> 0
CopyMemory ByVal s, b(36), 1024
'Debug.Print Left$(s, InStr(s, Chr(0)))
If InStr(1, LCase(s), LCase(sFileName)) > 0 Then
Running = True: Exit Do
End If
Loop
CloseHandle (hSnapshot)
End Function