Solved

How to terminate current applications running?

Posted on 2000-03-21
5
272 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

763 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

13 Experts available now in Live!

Get 1:1 Help Now