Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to kill a process.
Message
 
 
À
04/12/1999 13:31:07
Information générale
Forum:
Visual Basic
Catégorie:
Fonctions API de Windows
Divers
Thread ID:
00298619
Message ID:
00299667
Vues:
19
>>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.
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform