VB知道窗口句柄怎么得到进程句柄?
hProcess=GetForegroundWindow'获得前景窗口句柄'已经获得前景窗口句柄了怎么跟距这个窗口句柄得到它的进程句柄?VB知道窗口句柄怎么得到进程句柄?...
hProcess = GetForegroundWindow '获得前景窗口句柄
'已经获得前景窗口句柄了怎么跟距这个窗口句柄得到它的进程句柄?
VB知道窗口句柄怎么得到进程句柄? 展开
'已经获得前景窗口句柄了怎么跟距这个窗口句柄得到它的进程句柄?
VB知道窗口句柄怎么得到进程句柄? 展开
1个回答
展开全部
你是说进程Pid吗?
上面的hProcess最好用hWnd,是窗口句柄
用API:
新建模块,输入
Option Explicit
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
'自建函数
Public Function GetPidFromHWnd(ByVal hWnd As Long)As Long'返回值就是Pid
On Error Resume Next
Dim tPid As Long
Call GetWindowThreadProcessId(hWnd,tPid)
GetPidFromHWnd=tPid
End Function
模块Okay
调用就好了
PID(进程编号)=GetPidFromHWnd(hWnd)'这里的hWnd就是你上面的hProcess
上面的hProcess最好用hWnd,是窗口句柄
用API:
新建模块,输入
Option Explicit
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
'自建函数
Public Function GetPidFromHWnd(ByVal hWnd As Long)As Long'返回值就是Pid
On Error Resume Next
Dim tPid As Long
Call GetWindowThreadProcessId(hWnd,tPid)
GetPidFromHWnd=tPid
End Function
模块Okay
调用就好了
PID(进程编号)=GetPidFromHWnd(hWnd)'这里的hWnd就是你上面的hProcess
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询