I am using the following code to find the EXE of all the running processes. (This code is very stripped down to show only the essentials.) It works great on Windows 98. That is, it returns the full path of the program (e.g., "C:\Windows\Program.exe"). However, in XP this same code returns only the EXE file, without the path (e.g., "Program.exe"). For some aspects of my program, I need the full path. Specifically, the program is an anti-Trojan program designed to shut down any Trojan programs and optionally delete the file. In both 98 and XP this code allows me to shut down the program (using KillProcess(uProcess.th32ProcessID, 0)), but I need the full path to do a Kill afterward if the user elects to destroy the Trojan file. Someone please tell me how to get the full path under XP using the following code, or something very close to it using Visual Basic.
Here is my existing code, stripped to the essentials:



Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szexeFile As String * MAX_PATH
End Type

Declare Function ProcessFirst _
Lib "kernel32" Alias "Process32First" _
(ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Declare Function ProcessNext _
Lib "kernel32" Alias "Process32Next" _
(ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Declare Function CreateToolhelpSnapshot _
Lib "kernel32" Alias "CreateToolhelp32Snapshot" _
(ByVal lFlags As Long, _
lProcessID As Long) As Long
Declare Function CloseHandle _
Lib "kernel32" (ByVal hObject As Long) As Long

Sub ListPrograms()

uProcess.dwSize = Len(uProcess)
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
rProcessFound = ProcessFirst(hSnapshot, uProcess)
Do While rProcessFound
NumProcesses = NumProcesses + 1
i = InStr(1, uProcess.szexeFile, Chr(0))
szExename = LCase$(Left$(uProcess.szexeFile, i - 1))
MainForm.List1.AddItem szExename
rProcessFound = ProcessNext(hSnapshot, uProcess)
Loop
Call CloseHandle(hSnapshot)

End Sub