MikeG Level: Sage
 Registered: 21-02-2003 Posts: 54
|
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]
|