 |
|
 |
stickleprojects Level: Moderator

 Registered: 09-09-2002 Posts: 891
|
Re: Hwnd of all windows on screen
Hi,
Create a new app, with a form, button and listbox.
call the listbox list1
add the following code into a module:
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Function WindowEnumerator(ByVal app_hwnd As Long, ByVal lParam As Long) As Long
Dim length As Long
Dim Title As String
Dim buf As String * 256
length = GetWindowText(app_hwnd, buf, Len(buf))
If length = 0 Then
length = GetClassName(app_hwnd, buf, Len(buf))
End If
Title = Left$(buf, length)
Form1.List1.AddItem app_hwnd & vbTab & Title
WindowEnumerator = True
End Function
|
Now add the following to the form:
Private Sub Command1_Click()
Me.List1.Clear
EnumWindows AddressOf WindowEnumerator, 0
End Sub
|
Run and click the button.
The listbox is populated with the caption or classname of all windows.
Hope this helps,
Kieron
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
|
|
10-12-2005 at 02:53 PM |
|
|
|
|
 |
 |