module
VB Code:
  1. Option Explicit
  2. Public strstr As String
  3. Const MAX_PATH& = 260
  4.  
  5. Declare Function ProcessFirst _
  6. Lib "kernel32" Alias "Process32First" _
  7. (ByVal hSnapshot As Long, _
  8. uProcess As PROCESSENTRY32) As Long
  9.  
  10. Declare Function ProcessNext _
  11. Lib "kernel32" Alias "Process32Next" _
  12. (ByVal hSnapshot As Long, _
  13. uProcess As PROCESSENTRY32) As Long
  14.  
  15. Declare Function CreateToolhelpSnapshot _
  16. Lib "kernel32" Alias "CreateToolhelp32Snapshot" _
  17. (ByVal lFlags As Long, _
  18. lProcessID As Long) As Long
  19.  
  20. Declare Function CloseHandle _
  21. Lib "kernel32" (ByVal hObject As Long) As Long
  22.  
  23. Type PROCESSENTRY32
  24.      dwSize As Long
  25.      cntUsage As Long
  26.      th32ProcessID As Long
  27.      th32DefaultHeapID As Long
  28.      th32ModuleID As Long
  29.      cntThreads As Long
  30.      th32ParentProcessID As Long
  31.      pcPriClassBase As Long
  32.      dwFlags As Long
  33.      szexeFile As String * MAX_PATH
  34. End Type
  35.  
  36. Public Function IsRunning(Exename As String) As Boolean
  37. Const TH32CS_SNAPPROCESS As Long = 2&
  38. Dim uProcess As PROCESSENTRY32
  39. Dim rProcessFound As Long
  40. Dim hSnapshot As Long
  41. Dim szExename As String
  42. Dim i As Integer
  43.  
  44. uProcess.dwSize = Len(uProcess)
  45. hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
  46. rProcessFound = ProcessFirst(hSnapshot, uProcess)
  47. Do While rProcessFound
  48. i = InStr(1, uProcess.szexeFile, Chr(0))
  49. szExename = LCase$(Left$(uProcess.szexeFile, i - 1))
  50. rProcessFound = ProcessNext(hSnapshot, uProcess)
  51.     If InStr(LCase(szExename), LCase(Exename)) Then
  52.         IsRunning = True: Exit Do
  53.     End If
  54. Loop
  55. End Function

call it like If IsRunning("notepad.exe")= true then