嗯,正在尝试编写一个猴岛论坛专用记事本,已经完成了普通笔记本功能,HOOK屏蔽按键功能,QQ消息轰炸功能等,正在编写窗口信息查看功能,目前其他获取都没有问题,唯独在获取进程路径方面有问题,故来讨论
首先,类型的定义如下:
Public Type MODULEENTRY32
dwSize As Long
th32ModuleID As Long
th32ProcessID As Long
GlblcntUsage As Long
ProccntUsage As Long
modBaseAddr As Long
modBaseSize As Long
hModule As Long
szModule(256) As Byte
szExePath(256) As Byte
End Type
之后通过进程ID获取路径:
Public Function WindowsInformationFrm_GetProcessPath(ByVal PID As Long) As String
Dim Module As Long
Dim Mod32 As MODULEENTRY32
Module = CreateToolhelp32Snapshot(8, PID)
Mod32.dwSize = 548
Module32First Module, Mod32
CloseHandle Module
WindowsInformationFrm_GetProcessPath = Public_ByteToString(Mod32.szExePath)
End Function
字节数组转文本函数如下:
Public Function Public_ByteToString(Byt() As Byte) As String
Dim lpStr As String
For i = 0 To UBound(Byt)
lpStr = lpStr & ChrB(Byt(i))
Next
Public_ByteToString = StrConv(lpStr, vbUnicode)
End Function
但是现在获取到的路径是这样:
:\Program Files\Microsoft Visual Studio\VB98\vb6.exe
根本获取不到盘符,尝试修改类型声明时的数组长度,无解,尝试其他方法,依旧无解,故来寻求解决方法,望各位不吝赐教