I posted this a while ago, never posted in codebank. Probably will come in useful someday for someone..

VB Code:
  1. Option Explicit
  2.  
  3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
  4.     ByVal lpClassName As String, _
  5.     ByVal lpWindowName As String _
  6. ) As Long
  7.  
  8. Private Declare Function GetParent Lib "user32" ( _
  9.     ByVal hwnd As Long _
  10. ) As Long
  11.  
  12. Private Declare Function GetWindowThreadProcessId Lib "user32" ( _
  13.    ByVal hwnd As Long, _
  14.    lpdwProcessId As Long _
  15. ) As Long
  16. Private Declare Function GetWindow Lib "user32.dll" ( _
  17.     ByVal hwnd As Long, _
  18.     ByVal wCmd As Long _
  19. ) As Long
  20.  
  21. Private Const GW_HWNDNEXT As Long = 2
  22.  
  23. Private Sub Form_Load()
  24.     MsgBox IsPidRunning(2123)
  25. End Sub
  26.  
  27. Private Function IsPidRunning(Pid As Long) As Boolean
  28. Dim tmpHWND As Long
  29. Dim tmpPID As Long
  30. Dim tmpID As Long
  31.  
  32.     tmpHWND = FindWindow(vbNullString, vbNullString)
  33.  
  34.     Do While tmpHWND <> 0
  35.         If GetParent(tmpHWND) = 0 Then
  36.             tmpID = GetWindowThreadProcessId(tmpHWND, tmpPID)
  37.             If tmpPID = Pid Then
  38.                     'hwnd = tmpHWND
  39.                     IsPidRunning = True
  40.                 Exit Do
  41.             End If
  42.         End If
  43.  
  44.         tmpHWND = GetWindow(tmpHWND, GW_HWNDNEXT)
  45.     Loop
  46. End Function