'Get a list of Open Window Names using GetDesktopWindow,GetWindow and GetWindowText API
'Get a list of Open Window Names using GetDesktopWindow,GetWindow and GetWindowText API
API Declarations
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) 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 Const GW_CHILD = 5
Private Const GW_HWNDNEXT = 2
Rate 'Get a list of Open Window Names using GetDesktopWindow,GetWindow and GetWindowText API
(1(1 Vote))
'http://www.geocities.com/marskarthik
'http://marskarthik.virtualave.net
'Email: [email protected]
Private Sub Form_Load()
Dim dhwnd As Long, hwnd As Long, wc As Long, rval As Long
Dim wname As String, index As Long
dhwnd = GetDesktopWindow()
hwnd = GetWindow(dhwnd, GW_CHILD)
wc = 1: index = 0
Do While hwnd <> 0
wname = Space(260)
rval = GetWindowText(hwnd, wname, 260)
wname = Left(wname, InStr(wname, Chr(0)) - 1)
If Len(wname) Then
'MsgBox wname
List1.AddItem wname, index
index = index + 1
End If
hwnd = GetWindow(hwnd, GW_HWNDNEXT)
Loop
Label1.Caption = "Total number of Open Windows = " & index + 1
End Sub
'Get a list of Open Window Names using GetDesktopWindow,GetWindow and GetWindowText API Comments
No comments yet — be the first to post one!
Post a Comment