borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Launch VB via shell execute)Next Topic (Executable name from Thread handle?) New Topic New Poll Post Reply
AndreaVB Forum : API : Windows Task Manager - Applications Tab
Poster Message
MikeG
Level: Sage

Registered: 21-02-2003
Posts: 54

icon Windows Task Manager - Applications Tab

How can I scan through the "Windows Task Manager" Applications tab using VB?  I want to be able to read through all the programs currently running under the Applications tab and get the name of each program and it's hWindow.

[Edited by MikeG on 09-06-2004 at 10:32 AM GMT]

09-06-2004 at 06:30 PM
View Profile Send Email to User Show All Posts | Quote Reply
MikeG
Level: Sage

Registered: 21-02-2003
Posts: 54
icon Re: Windows Task Manager - Applications Tab

Ok, I figured it out.  I'm beginning to amaize myself.    For the bennifit of others, here's what I came up with.


Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetActiveWindow Lib "user32" () As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Public Function myFindWindow(ProgramName As String, Optional ReturnFullName As String) As Long
    Dim hWindow As Long
    Dim WinTitle As String
    Dim lenWinTitle As Long
    
    hWindow = FindWindow(vbNullString, vbNullString)
    hWindow = GetWindow(hWindow, GW_HWNDFIRST)
    
    
    Do While hWindow <> 0
        lenWinTitle = GetWindowTextLength(hWindow)
        WinTitle = Space$(lenWinTitle + 1)
        lenWinTitle = GetWindowText(hWindow, WinTitle, lenWinTitle + 1)
        WinTitle = Left$(WinTitle, Len(WinTitle) - 1)
        If LCase(ProgramName) = LCase(Left(WinTitle, Len(ProgramName))) Then
            ReturnFullName = WinTitle
            myFindWindow = hWindow
            Exit Function
        End If
        hWindow = GetWindow(hWindow, GW_HWNDNEXT)
    Loop
    myFindWindow = 0&
End Function



[Edited by MikeG on 10-06-2004 at 12:00 PM GMT]

[Edited by MikeG on 10-06-2004 at 12:00 PM GMT]

10-06-2004 at 07:59 PM
View Profile Send Email to User Show All Posts | Quote Reply
abecedario
Level: Trainee

Registered: 25-07-2005
Posts: 2
icon Re: Windows Task Manager - Applications Tab

I need to get the name of an application from the task manager using vb or vb.net after that i need to compare that name with another name that is stored in a database, Could any body help me with thise issue??  

____________________________
Dj**Abecedario

25-07-2005 at 11:12 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : API : Windows Task Manager - Applications Tab
Previous Topic (Launch VB via shell execute)Next Topic (Executable name from Thread handle?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder