Solved

How to terminate current applications running?

Posted on 2000-03-21
5
274 Views
Last Modified: 2010-08-05
I have an application which send a broadcast message to get the current tasks of a few applications which are currently running or not running. Following is an example of 16 bit application:
 
 //  Fill the m_ahtActiveList array with the Task handles of all active tasks
    //  This will also inform the Task that they need to exit
    //
    ::SendMessage(HWND_BROADCAST, RegisterWindowMessage(DNLDCOPY_MSG),
                  0, (LONG)(HTASK *)m_ahtActiveList);
   
where,
HTASK   m_ahtActiveList[5];

Before my application start processing(installing program), it need to close all the application that currently running. In 16 bit, there are GetCurrentTask() and IsTask() that would help to do the job. Is there any similar function in 32 bit? I would appreciate if anybody help me on this problem.
   
0
Comment
Question by:EKarim
  • 3
5 Comments
 
LVL 3

Expert Comment

by:ufolk123
ID: 2642958
Hi Ekarim,

You can use the Toolhelp APIs to enumerate all prcoesses currently tunning on the system ( Win95) .Then you need to open each process using openprocess() and call terminateprocess()


0
 

Author Comment

by:EKarim
ID: 2645785
Hi ufolk123,

Thanks for you reply. It took me longer to see your answer because I did not receive the e-mail after you posted your answer. Anyhow, Is there any limitation to enumerate process using ToolHelp API in Windows NT? My application should be able to run both in Win95 and Windows NT. I do not have any prior experience in ToolHelp API. Could you please write me in details about the functions that I need to accomplish the job. Do I still have to send a broadcast message to other executables? I only have to terminate 5 executables before my application start installing the files. Again, thanks for your help.
0
 

Author Comment

by:EKarim
ID: 2646606
Hi All,

I can not accept this because my application need to wait until closing all the applications gracefully. For example, if the printer application is running, my appliction need to wait until the printer application finish printing. I will highly appreciate if you go over my above posted questions if ToolHelp API is the best way to solve the problem. Thanks,

EKarim
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 75 total points
ID: 2647821
1.   HOWTO: Terminate an Application "Cleanly" in Win32
http://support.microsoft.com/support/kb/articles/Q178/8/93.ASP
2. //Processes list and kill by name
http://www.codeguru.com/win32/ps.shtml

In there articles you can find source
text for finding and closing 32b apps
for Windows 95/NT.
I hope, it helps. Alex
0
 

Author Comment

by:EKarim
ID: 2655507
I did not get all the answers. I am closing this because I know where I can start to solve the problem. Thanks for your help.

EKarim
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

775 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