community.borland.com

Article #15916: How to terminate all running applications

 Technical Information Database

TI916D.txt   How to terminate all running applications
Category   :Windows API
Platform    :All
Product    :Delphi  1.0

Description:
Q:  How do I terminate all running tasks?

A:  Below is some code that will help if you want to terminate ALL tasks,
    no questions asked.

A word of caution, before you run this for the first time, make sure
that you save it and anything else that may have some pending data.


procedure TForm1.ButtonKillAllClick(Sender: TObject);
var
  pTask   : PTaskEntry;
  Task    : Bool;
  ThisTask: THANDLE;
begin
  GetMem (pTask, SizeOf (TTaskEntry));
  pTask^.dwSize := SizeOf (TTaskEntry);

  Task := TaskFirst (pTask);
  while Task do
  begin
    if pTask^.hInst = hInstance then
      ThisTask := pTask^.hTask
    else
      TerminateApp (pTask^.hTask, NO_UAE_BOX);
    Task := TaskNext (pTask);
  end;
  TerminateApp (ThisTask, NO_UAE_BOX);
end;

Reference:


7/16/98 4:33:57 PM
 

Last Modified: 01-SEP-99