Not a Member Yet,
Click here to Register
How do you like the new design?

ID: 276
Viewed: 2267
Added: Jul 26, 2002
Snippet uploaded by: snippet
Written By: Mathew Gates
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

code that will get the basic running programs on the machine

code by Mathew Gates 09/05/2001

Add a listbox and a command button to a form and add this code

Highlight all by clicking in box
Option Explicit 

Private Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetParent Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function GetWindowTextLength Lib _
"user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long

Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal _
lpString As String, ByVal cch As Long) As Long


Private Sub LoadTaskList(frm As Form)
Dim CurrWnd As Long
Dim Length As Long
Dim TaskName As String
Dim Parent As Long

CurrWnd = GetWindow(frm.hwnd, GW_HWNDFIRST)

Do While CurrWnd <> 0
Parent = GetParent(CurrWnd)
Length = GetWindowTextLength(CurrWnd)
TaskName = Space$(Length + 1)
Length = GetWindowText(CurrWnd, TaskName, Length + 1)
TaskName = Left$(TaskName, Len(TaskName) - 1)

If Length > 0 Then
If TaskName <> frm.Caption Then
frm.List1.AddItem TaskName
End If
End If

CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)

End Sub

Highlight All
Private Sub Command1_Click() 
Call LoadTaskList(Me)
End Sub

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2018 All Rights Reserved. Conditions