Athenis
Nov 12th, 1999, 09:43 AM
Hi,
How can I get a name list of windows running on a system?
Thanks.
Aaron Young
Nov 12th, 1999, 10:19 AM
Try something like this:
In a Module..
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 EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public sWnds() As String
Public Function EnumProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim sString As String * 255
Call GetWindowText(hwnd, ByVal sString, 255)
If Left(sString, 1) <> Chr(0) Then
sWnds(UBound(sWnds)) = Left(sString, InStr(sString, Chr(0)) - 1)
ReDim Preserve sWnds(UBound(sWnds) + 1)
End If
EnumProc = hwnd
End Function
In the Form with a Listbox and Command Button..
Private Sub Command1_Click()
Dim iWnd As Integer
ReDim sWnds(0)
Call EnumWindows(AddressOf EnumProc, 0&)
List1.Clear
For iWnd = 0 To UBound(sWnds) - 1
List1.AddItem sWnds(iWnd)
Next
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net