level 1
西游脚本
楼主
GetWindowThreadProcessId
如果是告诉请你飘过直接无视。 很多人在RT 这个问题上每次得到的Pid都是0
到底怎么回事呢,我现在告诉大家 Private Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As Long, ByVal lpdwProcessId As Integer) As Integer ByVal hwnd As Long 其实 Hwnd 在vb.net 当调用这个api时。 ByVal hwnd As 的 不是 Long 也 不是 integer 而是 IntPtr 这个类型是 vb.net 中指定的一个用来表达 Hwnd 就是用来表示(句柄)的。那么这个api 需要的是 句柄 那么
正确的
声明如下
Private Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As IntPtr, ByVal lpdwProcessId As Integer) As Integer 调用方法还是和其他语言一样,老方法调用。 private sub 取进程Pid
dim 窗口句柄 as IntPtr '注意到这个变量的声明了吗? 是 intptr 如果你已经有了句柄是Long的类型的话很简单看下面
dim pid as Integer
窗口句柄 = 原来的窗口 '这里把类型转换下就可以
GetWindowThreadProcessId(窗口句柄,PID) msgbox pid ’这个时候你就能得到Pid了。
希望这个能对广大喜欢用 vb.net 的同志们帮助。 高手勿喷!其实这个鸟东西我也研究了很久。刚开始我也和大家一样取到的pid 都是0 一直是0 蛋都快碎了。
2012年08月26日 14点08分
1
如果是告诉请你飘过直接无视。 很多人在RT 这个问题上每次得到的Pid都是0
到底怎么回事呢,我现在告诉大家 Private Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As Long, ByVal lpdwProcessId As Integer) As Integer ByVal hwnd As Long 其实 Hwnd 在vb.net 当调用这个api时。 ByVal hwnd As 的 不是 Long 也 不是 integer 而是 IntPtr 这个类型是 vb.net 中指定的一个用来表达 Hwnd 就是用来表示(句柄)的。那么这个api 需要的是 句柄 那么
正确的
声明如下
Private Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As IntPtr, ByVal lpdwProcessId As Integer) As Integer 调用方法还是和其他语言一样,老方法调用。 private sub 取进程Pid
dim 窗口句柄 as IntPtr '注意到这个变量的声明了吗? 是 intptr 如果你已经有了句柄是Long的类型的话很简单看下面
dim pid as Integer
窗口句柄 = 原来的窗口 '这里把类型转换下就可以
GetWindowThreadProcessId(窗口句柄,PID) msgbox pid ’这个时候你就能得到Pid了。
希望这个能对广大喜欢用 vb.net 的同志们帮助。 高手勿喷!其实这个鸟东西我也研究了很久。刚开始我也和大家一样取到的pid 都是0 一直是0 蛋都快碎了。