1,486
社区成员
发帖
与我相关
我的任务
分享
'form1添加Command1和List1
Private Sub Command1_Click()
List1.Clear
EnumWindows AddressOf lpfunc, ByVal 0&
End Sub
'建立Module1添加以下内容
Option Explicit
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Const GW_OWNER = 4
Function lpfunc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim pstr As String, Ret As Long
If IsWindowVisible(hwnd) = False Then GoTo continu
If GetWindow(hwnd, GW_OWNER) <> 0 Then GoTo continu
Ret = GetWindowTextLength(hwnd)
pstr = Space(Ret)
If GetWindowText(hwnd, pstr, Ret + 1) = 0 Then GoTo continu
If pstr <> "" And pstr <> "Program Manager" Then Form1.List1.AddItem pstr
continu:
lpfunc = True
End Function