Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking to see if a program is running
Message
From
05/12/2002 05:26:22
 
 
To
04/12/2002 21:02:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00729488
Message ID:
00729805
Views:
22
>How does one kill a process?

The preferred method is to send a WM_CLOSE message to the primary thread of the process (you need a thread ID, and then send the WM_CLOSE using the Win32 API call PostThreadMessage) to allow for noprmal termination; if you can get a Process handle with the PROCESS_TERMINATE permission, you can issue a TerminateProcess() API call to shut down the process, but in a very messy and immediate fashion - TerminateProcess() does not give the target process a chance to clear buffers, release resources and the like - it just causes it to die as quickly as possible. There is sample code in the FAQ and in my API_APPRUN class in the Files section for TerminateProcess(), and I think I posted sample code for PostThreadMessage in the Win32 section - if not, it's in a message I posted in the last couple of months.

There are also command line utilities like KILL.EXE that can be run to accomplish much the same thing, but you'll still need an OS-recognized identifier for the process (a ProcessID) to have it go and do the work for you. KILL.EXE is a part of the NT/Win2K Resource Kit.
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform