MAybe these APIs and functions will work..

VB Code:
  1. Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
  2. Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
  3. Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessId As Long, ByVal dwType As Long) As Long
  4. Public Const RSP_SIMPLE_SERVICE = 1
  5. Public Const RSP_UNREGISTER_SERVICE = 0
  6. Private Const PROCESS_ALL_ACCESS = &H1F0FFF
  7.  
  8. Private Declare Function OpenProcess Lib "kernel32" _
  9.   (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
  10.    ByVal dwProcessId As Long) As Long
  11.  
  12. Private Declare Function GetExitCodeProcess Lib "kernel32" _
  13.    (ByVal hProcess As Long, lpExitCode As Long) As Long
  14.  
  15. Private Declare Function TerminateProcess Lib "kernel32" _
  16.    (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  17.  
  18.    Private Type PROCESSENTRY32
  19.   dwSize As Long
  20.   cntUsage As Long
  21.   th32ProcessID As Long
  22.   th32DefaultHeapID As Long
  23.   th32ModuleID As Long
  24.   cntThreads As Long
  25.   th32ParentProcessID As Long
  26.   pcPriClassBase As Long
  27.   dwFlags As Long
  28.   szExeFile As String * 260
  29. End Type
  30.  
  31. Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
  32. Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
  33.  
  34. Private Const PROCESS_TERMINATE = &H1
  35. Public Const VER_PLATFORM_WIN32_WINDOWS = 1
  36. Private Const PROCESS_QUERY_INFORMATION = 1024
  37. Private Const PROCESS_VM_READ = 16
  38. Private Const TH32CS_SNAPPROCESS = &H2
  39.  
  40. Public Function GetEXEProcessID(ByVal sEXE As String) As Long
  41.   Dim aPID() As Long
  42.   Dim lProcesses As Long
  43.   Dim lProcess As Long
  44.   Dim lModule As Long
  45.   Dim sName As String
  46.   Dim iIndex As Integer
  47.   Dim bCopied As Long
  48.   Dim lSnapShot As Long
  49.   Dim tPE As PROCESSENTRY32
  50.   Dim bDone As Boolean
  51.   Dim lRet As Long
  52.  
  53.   If CheckVersion() = VER_PLATFORM_WIN32_WINDOWS Then
  54.     'Windows 9x
  55.     'Create a SnapShot of the Currently Running Processes
  56.     lSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
  57.     If lSnapShot < 0 Then Exit Function
  58.     tPE.dwSize = Len(tPE)
  59.     'Buffer the First Processes Info..
  60.     bCopied = Process32First(lSnapShot, tPE)
  61.     Do While bCopied
  62.       'While there are Processes List them..
  63.       sName = Left$(tPE.szExeFile, InStr(tPE.szExeFile, Chr(0)) - 1)
  64.       sName = Mid(sName, InStrRev(sName, "\") + 1)
  65.       If InStr(sName, Chr(0)) Then
  66.         sName = Left(sName, InStr(sName, Chr(0)) - 1)
  67.       End If
  68.       bCopied = Process32Next(lSnapShot, tPE)
  69.       If StrComp(sEXE, sName, vbTextCompare) = 0 Then
  70.         GetEXEProcessID = tPE.th32ProcessID
  71.         Exit Do
  72.       End If
  73.     Loop
  74.    
  75.   Else
  76.     'Windows NT
  77.     'The EnumProcesses Function doesn't indicate how many Process there are,
  78.     'so you need to pass a large array and trim off the empty elements
  79.     'as cbNeeded will return the no. of Processes copied.
  80.     ReDim aPID(255)
  81.     Call EnumProcesses(aPID(0), 1024, lProcesses)
  82.     lProcesses = lProcesses / 4
  83.     ReDim Preserve aPID(lProcesses)
  84.    
  85.     For iIndex = 0 To lProcesses - 1
  86.       'Get the Process Handle, by Opening the Process
  87.       lProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, aPID(iIndex))
  88.       If lProcess Then
  89.         'Just get the First Module, all we need is the Handle to get
  90.         'the Filename..
  91.         If EnumProcessModules(lProcess, lModule, 4, 0&) Then
  92.           sName = Space(260)
  93.           Call GetModuleFileNameExA(lProcess, lModule, sName, Len(sName))
  94.           If InStr(sName, "\") > 0 Then
  95.             sName = Mid(sName, InStrRev(sName, "\") + 1)
  96.           End If
  97.           If InStr(sName, Chr(0)) Then
  98.             sName = Left(sName, InStr(sName, Chr(0)) - 1)
  99.           End If
  100.           If StrComp(sEXE, sName, vbTextCompare) = 0 Then
  101.             GetEXEProcessID = aPID(iIndex)
  102.             bDone = True
  103.           End If
  104.         End If
  105.         'Close the Process Handle
  106.         lRet = CloseHandle(lProcess)
  107.         If bDone Then Exit For
  108.       End If
  109.     Next
  110.   End If
  111. End Function
  112.  
  113. Public Function TerminateEXE(ByVal sEXE As String) As Boolean
  114.   Dim lPID As Long
  115.   Dim lProcess As Long
  116.  
  117.   lPID = GetEXEProcessID(sEXE)
  118.   If lPID = 0 Then Exit Function
  119.   lProcess = OpenProcess(PROCESS_TERMINATE, 0, lPID)
  120.   Call TerminateProcess(lProcess, 0&)
  121.   Call CloseHandle(lProcess)
  122.  
  123.   TerminateEXE = True
  124. End Function
  125.  
  126. Public Function EndShelledProcess(ShellReturnValue As Long) _
  127.    As Boolean
  128.  
  129. 'PURPOSE: End a process started with VB's Shell Statement
  130. 'INPUT: Task ID returned by Shell
  131. 'RETURNS: True if succesful, false otherwise
  132.  
  133. On Error Resume Next
  134.  
  135. Dim hInst As Long
  136. Dim hProcess As Long
  137. Dim lExitCode As Long
  138. Dim lRet As Long
  139.  
  140. hInst = ShellReturnValue
  141. If hInst = 0 Then Exit Function
  142.  
  143. 'Get handle to process
  144. hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0&, hInst)
  145. If hProcess <> 0 Then
  146.     'get exit code
  147.     GetExitCodeProcess hProcess, lExitCode
  148.         If lExitCode <> 0 Then
  149.                 'bye-bye
  150.             lRet = TerminateProcess(hProcess, lExitCode)
  151.             EndShelledProcess = lRet > 0
  152.         End If
  153. End If
  154.  
  155. End Function