Results 1 to 3 of 3

Thread: I am a man who dresses as a woman...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516

    Exclamation

    ...just joking.

    Is there a way to get all the files in the task bar and their hWnds? Or their names so I can use FindWindow.

    Any help would be useful.

    Thanks,

    Me
    Courgettes.

  2. #2
    Lively Member
    Join Date
    Apr 2000
    Location
    Hell
    Posts
    89

    Cool

    To enumerate all the top-level windows in the system, you need to call EnumWindows, and filter out the various properties to get the ones that are just in the taskbar.

    It just so happens I have such a function for a similar purpose.

    Code:
    ' Stick this in a module.
    
    Private EnumWindowsArray() As Long, wsMask As Long, wsStyles As Long, ewaCount As Long
    
    Public Enum WindowStyleConstants
      WS_OVERLAPPED = &H0
      WS_POPUP = &H80000000
      WS_CHILD = &H40000000
      WS_MINIMIZE = &H20000000
      WS_VISIBLE = &H10000000
      WS_DISABLED = &H8000000
      WS_CLIPSIBLINGS = &H4000000
      WS_CLIPCHILDREN = &H2000000
      WS_MAXIMIZE = &H1000000
      WS_CAPTION = &HC00000                '/* WS_BORDER | WS_DLGFRAME  */
      WS_BORDER = &H800000
      WS_DLGFRAME = &H400000
      WS_VSCROLL = &H200000
      WS_HSCROLL = &H100000
      WS_SYSMENU = &H80000
      WS_THICKFRAME = &H40000
      WS_GROUP = &H20000
      WS_TABSTOP = &H10000
    
      WS_MINIMIZEBOX = &H20000
      WS_MAXIMIZEBOX = &H10000
    
      WS_TILED = WS_OVERLAPPED
      WS_ICONIC = WS_MINIMIZE
      WS_SIZEBOX = WS_THICKFRAME
    
    '/*
    ' * Common Window Styles
    ' */
      WS_OVERLAPPEDWINDOW = WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
      WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
      WS_POPUPWINDOW = WS_POPUP Or WS_BORDER Or WS_SYSMENU
      WS_CHILDWINDOW = WS_CHILD
    End Enum
    
    
    ' *************************************
    ' *         CALLBACK FUNCTION         *
    ' *************************************
    
    Private Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
    '  Debug.Print "(" & GetWindowLong(hWnd, GWL_STYLE) & " & " & wsMask & ") = " & (GetWindowLong(hWnd, GWL_STYLE) And WS_VISIBLE) & " vs " & wsStyles
      If (GetWindowLong(hWnd, GWL_STYLE) And wsMask) = wsStyles Then
        ReDim Preserve EnumWindowsArray(0 To ewaCount)
        EnumWindowsArray(ewaCount) = hWnd
        ewaCount = ewaCount + 1
      End If
      EnumWindowsProc = 1 ' to cont. enumeration
    End Function
    
    Public Function EnumerateWindows(ByRef hWndArray() As Long, Optional ByVal WinStyleMask As WindowStyleConstants = 0, Optional ByVal WinStyleVal As WindowStyleConstants = 0) As Long
      ReDim EnumWindowsArray(0)
      ewaCount = 0
      wsMask = WinStyleMask
      wsStyles = WinStyleVal
      EnumWindows AddressOf EnumWindowsProc, 0
      hWndArray = EnumWindowsArray
      EnumerateWindows = ewaCount
    End Function
    
    ' ************
    
    ' Then call it like this:
    
    Private Sub Command1_Click()
      Dim hWnds() As Long, wndCount As Long
      wndCount = EnumerateWindows(hWnds, WS_CAPTION Or WS_VISIBLE, WS_CAPTION Or WS_VISIBLE)
    End Sub
    
    ' The WS_CAPTION or WS_VISIBLE usually nails it on the styles.
    - Steve

    Real programmers use COPY CON PROGRAM.EXE

  3. #3
    Addicted Member Razzle's Avatar
    Join Date
    Jan 2000
    Location
    Berlin, Germany
    Posts
    161
    To enumerate all running processes:

    Code:
        ReDim RProcesses(0)
        hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
       
        If hSnapShot = 0 Then Exit Sub
    
        uProcess.dwSize = Len(uProcess)
        r = ProcessFirst(hSnapShot, uProcess)
        i = 1
        Do While r
            ReDim Preserve RProcesses(UBound(RProcesses) + 1)
            RProcesses(i) = uProcess
            Form1.List1.AddItem uProcess.szExeFile
            i = i + 1
            r = ProcessNext(hSnapShot, uProcess)
    
        Loop
    
        Call CloseHandle(hSnapShot)
    
    End Sub
    Razzle
    ICQ#: 31429438
    What is the difference between a raven?
    -The legs. The length is equal, especially the right one.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width