想绕过防火墙,然后读取textbox的句柄的详细过程~~~

解决方案 »

  1.   


    Private Const LB_DELETESTRING = &H182
    Private Const LB_ADDSTRING = &H180Const GW_HWNDFIRST = 0
    Const GW_HWNDLAST = 1
    Const GW_HWNDNEXT = 2
    Const GW_HWNDPREV = 3
    Const GW_OWNER = 4
    Const GW_CHILD = 5
    Const GW_MAX = 5
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    Dim chWnd As Long
    Dim listHwnd As LongPrivate Sub Form_Load()
      Dim chGwnd As Long
      Dim clsname As String * 256
      chWnd = FindWindow(vbNullString, "fvflove") '"fvflove"改为窗口的名称要用全称
      chGwnd = GetWindow(chWnd, GW_CHILD)
      GetClassName chGwnd, clsname, 256
      If InStr(1, clsname, "TextBox") Then
        listHwnd = chGwnd '此处是返回的TextBox的句柄 ,你可以放入一个集合或数组
        Exit Sub
      End If
      While chGwnd <> 0
        chGwnd = GetWindow(chGwnd, GW_HWNDNEXT)
        GetClassName chGwnd, clsname, 256
        If InStr(1, clsname, "TextBox") Then
          listHwnd = chGwnd '此处是返回的TextBox的句柄 ,你可以放入一个集合或数组
          Exit Sub
        End If
      Wend
    End Sub
      

  2.   

    读取textbox和绕过防火墙有什么必然的联系吗?
      

  3.   

    谢谢fvflove
    还想问下我想读取句柄以及textbox内的内容,应该调用哪个API参数??
    还有就是如何把取出来的句柄和内容显示出来
    小弟菜鸟,先谢过了~~~
      

  4.   

    同问。
    另外,二楼的朋友以为TextBox的类名就是"TextBox"吗?
      

  5.   


    '请注意
    '我用的是
    InStr(1, clsname, "TextBox") '不是表示类名是TextBox.
    '而是表示类名中只要有TextBox字节.'设定取得了句柄为 Hwnd
    '以下是取得其文本内容的代码:
    Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As LongDim TextLen As Long
    Dim clsText As String * 256TextLen = GetWindowTextLength(hwnd)
    GetWindowText hwnd, clsText, TextLen + 1