Solved

Killing a process in Windows 95

Posted on 1998-07-09
6
240 Views
Last Modified: 2013-11-19
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?
0
Comment
Question by:mcsilver
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:trestan
ID: 1318914
You can use kill statement to terminates a user's process based on the system process ID.
0
 
LVL 1

Author Comment

by:mcsilver
ID: 1318915
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.
0
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 100 total points
ID: 1318916
Given a window title who's process you wish to terminate, you can do this:
1. FindWindow() to get the widnow handle
2. GetWindowThreadProcessId to get the process ID
3.TerminateProcess to kill the process
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:mcsilver
ID: 1318917
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.
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1318918
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
0
 
LVL 1

Author Comment

by:mcsilver
ID: 1318919
Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question