|
-
May 23rd, 2010, 12:02 PM
#7
Re: How to get full path of running process?
Good times.
vb Code:
Public Const PROCESS_QUERY_INFORMATION As Long = (&H400)
Public Const PROCESS_VM_READ As Long = (&H10)
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, ByVal cb As Long, ByRef cbNeeded As Long) As Long
Public Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, ByRef lphModule As Long, ByVal cb As Long, ByRef lpcbNeeded As Long) As Long
Public Declare Function GetModuleFileNameEx Lib "psapi.dll" Alias "GetModuleFileNameExA" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long
Private Sub PrintProc(ProcessID As Long)
Dim hProc As Long, hMod As Long, cbNeeded As Long
Dim strBuff As String, lRet As Long
strBuff = Space(260)
hProc = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, ProcessID)
If hProc <> 0 Then
If EnumProcessModules(hProc, hMod, 4&, cbNeeded) Then
lRet = GetModuleFileNameEx(hProc, hMod, strBuff, 260)
strBuff = Left$(strBuff, lRet)
Debug.Print ProcessID & " " & strBuff
End If
CloseHandle hProc
End If
End Sub
Public Function GetProcess()
Dim aProcess(1023) As Long, cbNeeded As Long, cProcess As Long, I As Long
EnumProcesses ByVal VarPtr(aProcess(0)), 1024 * 4, cbNeeded
cProcess = cbNeeded / 4
For I = 0 To cProcess
PrintProc aProcess(I)
Next I
End Function
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|