Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

How to terminate current applications running?

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
EKarim
Asked:
EKarim
  • 3
1 Solution
 
ufolk123Commented:
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
 
EKarimAuthor Commented:
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
 
EKarimAuthor Commented:
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
 
AlexVirochovskyCommented:
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
 
EKarimAuthor Commented:
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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now