VB句柄问题
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch 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
Private Const MaxControlUnit = 65535
Private Sub Timer5_Timer()
Dim hwnd As Long
Dim hWnd2 As Long
Dim Caption As String * 255
Dim ClassName As String * 255
Dim Output As String
Dim i As Long
hwnd = FindWindow(vbNullString, "软件名")
For i = 0 To MaxControlUnit
hWnd2 = FindWindowEx(hwnd, hWnd2, vbNullString, vbNullString)
If hWnd2 > 0 Then
GetClassName hWnd2, ClassName, Len(ClassName)
GetWindowText hWnd2, Caption, Len(Caption)
Output = "句柄是:" & hWnd2 & " " & "类名为:" & ClassName
Text1.Text = Caption
Else
Exit For
End If
Next
End Sub
希望高人能把他写函数之类的。
可以多个窗口调用,既能立刻刷新窗口上面的信息。。。
因为本人不是很懂VB句柄,希望能帮忙改下。。。谢谢!