win32 Api


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: win32 Api

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    win32 Api

    [Originally posted by jack]

    Does anybody know how to find the application list in WinNT through Win32 API same as the contents under the tab "applications" of task manager.which api i should use?

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:win32 Api

    [Originally posted by Karlis]

    try code something like:-

    Private Const GW_HWNDFIRST = 0
    Private Const GW_HWNDLAST = 1
    Private Const GW_HWNDNEXT = 2
    Private Const GW_HWNDPREV = 3
    Private Const GWL_STYLE = (-16)

    Private Declare Function ShowWindow Lib "User32" (ByVal hWnd As Long, ByVal flgs As Long) As Long
    Private Declare Function GetWindow Lib "User32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function GetWindowWord Lib "User32" (ByVal hWnd As Long, ByVal wIndx As Long) As Long
    Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As Long) As Long
    Private Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpSting As String, ByVal nMaxCount As Long) As Long
    Private Declare Function GetWindowTextLength Lib "User32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
    Private Declare Function SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal insaft As Long, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal flgs As Long) As Long

    Sub tasklist()

    Dim hwCurr As Long
    Dim intLen As Long
    Dim strTitle As String
    ' process all top-level windows in master window list

    hwCurr = GetWindow(Me.hWnd, GW_HWNDFIRST) ' get first window
    Do While hwCurr ' repeat for all windows
    If hwCurr <> Me.hWnd And TaskWindow(hwCurr) Then
    intLen = GetWindowTextLength(hwCurr) + 1 ' Get length
    strTitle = Space$(intLen) ' Get caption
    intLen = GetWindowText(hwCurr, strTitle, intLen)
    If intLen > 0 Then ' If we have anything show it
    MsgBox strTitle
    End If
    End If
    hwCurr = GetWindow(hwCurr, GW_HWNDNEXT)
    Loop

    End Sub



    Function TaskWindow(hwCurr As Long) As Long

    Dim lngStyle As Long
    lngStyle = GetWindowLong(hwCurr, GWL_STYLE)
    If (lngStyle And IsTask) = IsTask Then TaskWindow = True

    End Function

    Private Sub Form_Load()
    tasklist
    End Sub

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:win32 Api

    [Originally posted by jack]

    thanks for the answer. But it seems not I want. when I run this sample, more windows come up than what are listed in the task manager. I guess there are many child window alos shown up. How to filter those windows? And when I want to close the application, I close all the child windows of the parent window, which is exactly what task manager does.

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:win32 Api

    [Originally posted by Karlis]

    A good complete solution covering
    Tasklist Manager is located at:-

    http://www.mvps.org/vb/

    in the samples section download tasklist.zip

    knowledge in using classes and
    Win32 api is required to understand the code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center