当前位置:编程学习 > VB >>

VB句柄问题,希望高人帮忙

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private 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句柄,希望能帮忙改下。。。谢谢!


这样的话要加入很多的Timer控件和重复的代码。。。才能使实现获取多个窗口。。。
我想一个Timer一个代码同时获取多个窗体。。。。帮帮忙 --------------------编程问答-------------------- http://download.csdn.net/detail/nerozs/4507463
刚做的,鉴于csdn改版后的下载不返回下载分,只返回1分,被迫无奈,只能顺便赚点下载分。有需要的可以下载研究。 --------------------编程问答--------------------
补充:VB ,  网络编程
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,