|
-
Oct 22nd, 2000, 06:33 AM
#1
Thread Starter
Fanatic Member
In my program, I would like to have a list with all the open programs/windows on my pc. How do I do that???
Also, how can u close running programs or windows using the list that has all the window names.
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Oct 22nd, 2000, 06:43 AM
#2
Hyperactive Member
If you actually use the search feature of this page you'll find your answers quicker than just sitting there waiting for someone to do your homework .
*Throws the Dog a Bone* 
http://forums.vb-world.net/showthrea...threadid=30190
[]P
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Oct 22nd, 2000, 07:27 AM
#3
transcendental analytic
*Throws the Dog another bone*
Code:
'Put this in a module, getwindows will return with an array of handles
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private handles&(), counter&
Private Function EnmWinProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sCaption As String * 255
ReDim Preserve handles(counter)
handles(counter) = hwnd
counter = counter + 1
EnumWindowsProc = hwnd
End Function
Public Function GetWindows()
ReDim handles(0)
counter = 0
Call EnumWindows(AddressOf EnmWinProc, 0&)
GetWindows = handles
End Function
'Put this on the form
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const WM_CLOSE = &H10
Const WM_DESTROY = &H2
'And hows you use them:
For Each n In GetWindows
'To add it to a list
List1.AddItem n
'To close them:
PostMessage n, WM_CLOSE, 0, 0
PostMessage n, WM_DESTROY, 0, 0
Next n
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|
Click Here to Expand Forum to Full Width
|