Link to home
Start Free TrialLog in
Avatar of mcsilver
mcsilverFlag for Canada

asked on

Killing a process in Windows 95

I would like my MFC program to be able to kill any running process (I'm in Windows 95).  Must I get a list of all running processes?  If so, how?  Can I specify it by PID or program title or title bar title?
Avatar of trestan
trestan
Flag of Canada image

You can use kill statement to terminates a user's process based on the system process ID.
Avatar of mcsilver

ASKER

I looked up the KILL statement in the Dev Studio 5 help and it appears to only apply to SQL Server.  Will this work for any running (or sleeping) process running in the Windows 95 environment?  Also, how can I get a list of PIDs to know the PID number to send to the KILL statement?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of MikeP090797
MikeP090797

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.  This very sufficiently answers my question.  A couple things I'm still wondering, however: 1) is it possible to get a list of all running processes?  and 2) It appears that ExitProcess() is much safer and cleaner than TerminateProcess() and I should use ExitProcess().  But judging by its parameters, it doesn't appear possible to call ExitProcess() on any given process - just the process that calls ExitProcess().  Am I missing something here?

Thanks.
Avatar of MikeP090797
MikeP090797

You can call ExitProcess for the calling process only. You can use EnumWindows to get the list of all windows, and then use GetWindowThreadProcessId to get each's process. Of course, you'll have to check for duplicate id's, cause one process may have more then 1 window
Thanks!