如何用GetWindow函数来列举桌面上的窗口

来源:互联网 发布:超级基因优化 编辑:程序博客网 时间:2024/05/21 06:31
Dim RenHWND As Integer, WinText As String * 256
     t% = 0: lstWindows.Clear
     RenHWND = GetWindow(frmTop.hWnd, GW_HWNDFIRST)
     Do
     i% = GetWindowText(RenHWND, WinText, 256)
     If i% <> 0 Then
     l% = GetWindowTextLength(RenHWND)
     If Left$(WinText, l%) <> frmTop.Caption And Left$(WinText, l%) <> App.Title Then
     lstWindows.AddItem WinText: ReDim Preserve winHWND(t%) As Integer
     winHWND(t%) = RenHWND: t% = t% + 1
     End If
     End If
     RenHWND = GetWindow(RenHWND, GW_HWNDNEXT)
     Loop Until RenHWND = 0
     lstWindows.ListIndex = 0