100分,求vb EnumChildWindows,EnumChildProc实例源程序
发布网友
发布时间:2023-11-05 15:05
我来回答
共1个回答
热心网友
时间:2024-12-05 06:22
窗体代码如下 添加一个按钮 一个list控件
Private Sub Command1_Click()
EnumChildWindows GetDesktopWindow, AddressOf EnumChildProc, ByVal 0&
End Sub
模块代码如下
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String * 255
GetWindowText hwnd, sSave, 255
If Blank(sSave) <> "" Then Form1.List1.AddItem hwnd & "," & sSave
EnumChildProc = 1
End Function
Public Function Blank(ByVal szString As String) As String
Dim l As Integer
l = InStr(szString, Chr(0))
If l > 0 Then
Blank = Left(szString, l - 1)
Else
Blank = szString
End If
End Function