-
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?
-
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
-
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.
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks