Solved

How to terminate current applications running?

Posted on 2000-03-21
5
273 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now