VB根据进程PID值获取进程完整路径,VB根据进程PID值获取进程路径,VB根据进程PID获取进程完整路径,VB根据进程PID获取进程路径,VB根据PID值获取进程完整路径,VB根据PID获取进程完整路径,VB根据PID值获取进程路径,VB根据PID获取进程路径,VB根据PID获取路径,VB根据PID取进程路径,VB根据PID取路径,VB PID获取进程路径,VB PID获取路径,VB PID进程路径,VB PID路径,VB PID

VB根据进程PID值获取进程完整路径:

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long '打开进程
Private Declare Function EnumProcessModules Lib "psapi.dll " (ByVal hProcess As Long, lphModule As Long, ByVal cb As Long, cbNeeded As Long) As Long '枚举进程模块
Private Declare Function GetModuleFileNameExA Lib "psapi.dll " (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long '获取模块文件名
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long '关闭句柄

Public Function GetProcPath(PID As Long) As String                              '根据PID获取进程路径
    On Error GoTo over
    Dim tmp As Long, Process As Long, Modules(255) As Long, Path As String * 512
    Process = OpenProcess(&H400 Or &H10, 0, PID)                                '打开进程
    If Process = 0 Then GoTo over                                               '判断进程打开是否成功
    If EnumProcessModules(Process, Modules(0), 256, tmp) <> 0 Then GetProcPath = Replace(Left$(Path, GetModuleFileNameExA(Process, Modules(0), Path, 256)), "\??\", "") '枚举模块成功 '取得路径'处理字串并返回
over:
    Call CloseHandle(Process)                                                   '关闭句柄
End Function

GetProcPath (Upc.th32ParentProcessID)                                           '根据PID获得进程路径

留言评论(旧系统):

佚名 @ 2013-03-09 10:30:02

很好很强大

本站回复:

╮(╯_╰)╭