Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to kill a process.
Message
De
07/12/1999 09:46:55
 
 
Information générale
Forum:
Visual Basic
Catégorie:
Fonctions API de Windows
Divers
Thread ID:
00298619
Message ID:
00299726
Vues:
25
>>>How would I go about killing a process from VB. Much like CTRL+ALT+DEL end task. I have several tasks I wish to be able to kill on demand.
>>>
>>>Ideally I would loop thru all the processes and kill any not on the 'approved' list. But, I dont know what to even begin to look this up under.
>>>
>>
>>If you can get the Process handle for the process, you can issue a TerminateProcess(); the problem lies in the mechanism for retrieving the processes which is platform-dependent. You might want to look at using the CreateToolhelp32Snapshot API call with Win9x or Win2K, and then wander through the snapshot using Process32First/Process32Next to retrieve the PROCESSENTRY32 structures, which contain detailed information about each process running at the time of the snapshot.
>>
>>TerminateProcess() is a messy shutdown; you'd be better off using SendMessage() to issue a WM_QUIT to the main window of the process, but there's no guarentee that the message will be accepted or executed. TerminateProcess() is an absolute kill, but has a tendency to leave .DLLs in an unpredictable state after their use.
>>
>>If you don't have access to an MSDN Library, get it - you're going to need this; process management from an app, especially in an NT or WIn2K envrionment, is not trivial.
>
>Thanks Ed, I am looking into this now. Some of the processes I need to kill do not have any visual components. I very much appreciate the info.

But they do have a WinMain in all probability that accepts Windows Messages; TerminateProcess() doesn't give a hoot about UI.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform