首先,我给一下代码:
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As IntPtr, lpdwProcessId As Integer) As Integer
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim pid As Integer
GetWindowThreadProcessId(Val(TextBox1.Text), pid)
MsgBox(Str(pid))
End Sub
接着,我说一下问题:
问题:不管怎么调试,返回的pid都是0(给出的句柄都是正确的,存在的)
最后,十分诚恳的希望各位老师能帮一下忙!小子我都快崩溃了!
------解决方案--------------------
调GetLastError()看看是什么错误
------解决方案--------------------
确认Val(TextBox1.Text)每次都正确,你看看窗体的handle和Val(TextBox1.Text)一致吗
------解决方案--------------------
你 对 GetWindowThreadProcessId用法 理解错了!
请参照:http://blog.csdn.net/coolszy/article/details/5524163