Public Function GetCurPoshWnd() As Long '获取鼠标处窗口句柄
Dim tP As POINTAPI
GetCursorPos tP
GetCurPoshWnd = WindowFromPoint(tP.x, tP.y)
End Function
Public Function hWndToPid(hWnd As Long) As Long '获取指定窗口句柄进程的ID
Dim Ret As Long
GetWindowThreadProcessId hWnd, Ret
hWndToPid = Ret
End Function
Public Function PidToProcessName(Pid As Long) As String '用PID获取进程名
Dim Handle As Long
Dim Mod32 As MODULEENTRY32
Handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Pid)
Mod32.dwSize = 548
Module32First Handle, Mod32
CloseHandle Handle
PidToProcessName = BytToStr(Mod32.szModule)
End Function
Public Function PidToProcessPath(Pid As Long) As String 'PID获取进程路径
Dim lpStr As String * 255
Dim Handle As Long
Handle = OpenProcess(PROCESS_ALL_ACCESS, 0, Pid)
GetModuleFileNameEx Handle, 0, lpStr, 255
CloseHandle Handle
PidToProcessPath = Trim(lpStr)
End Function
Public Function BytToStr(Byt() As Byte) As String '转换格式用的
Dim lpStr As String
For i = 0 To UBound(Byt)
lpStr = lpStr & ChrB(Byt(i))
Next
BytToStr = StrConv(lpStr, vbUnicode)
End Function
= =一些低级玩意儿。。。以前闲着蛋疼写的。。。注释有写用途。。。API和类型的声明就不写了。。。