VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



'Get a list of Open Window Names using GetDesktopWindow,GetWindow and GetWindowText API

by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 23rd January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

'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



'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

Download this snippet    Add to My Saved Code

'Get a list of Open Window Names using GetDesktopWindow,GetWindow and GetWindowText API Comments

No comments have been posted about 'Get a list of Open Window Names using GetDesktopWindow,GetWindow and GetWindowText API. Why not be the first to post a comment about 'Get a list of Open Window Names using GetDesktopWindow,GetWindow and GetWindowText API.

Post your comment

Subject:
Message:
0/1000 characters