home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / del2faq.zip / TI2856.ZIP / TI2856.ASC
Text File  |  1996-02-28  |  1KB  |  43 lines

  1.    NUMBER  :  2856
  2.   PRODUCT  :  Delphi
  3.   VERSION  :  1.0
  4.        OS  :  Windows
  5.      DATE  :  February 28, 1996                       
  6.  
  7.     TITLE  :  How to terminate all running applications
  8.  
  9. Q:  How do I terminate all running tasks?
  10.  
  11. A:  Below is some code that will help if you want to terminate ALL tasks,
  12.     no questions asked.
  13.  
  14. A word of caution, before you run this for the first time, make sure
  15. that you save it and anything else that may have some pending data.
  16.  
  17.  
  18. procedure TForm1.ButtonKillAllClick(Sender: TObject);
  19. var
  20.   pTask   : PTaskEntry;
  21.   Task    : Bool;
  22.   ThisTask: THANDLE;
  23. begin
  24.   GetMem (pTask, SizeOf (TTaskEntry));
  25.   pTask^.dwSize := SizeOf (TTaskEntry);
  26.  
  27.   Task := TaskFirst (pTask);
  28.   while Task do
  29.   begin
  30.     if pTask^.hInst = hInstance then
  31.       ThisTask := pTask^.hTask
  32.     else
  33.       TerminateApp (pTask^.hTask, NO_UAE_BOX);
  34.     Task := TaskNext (pTask);
  35.   end;
  36.   TerminateApp (ThisTask, NO_UAE_BOX);
  37. end;
  38.  
  39. DISCLAIMER: You have the right to use this technical information
  40. subject to the terms of the No-Nonsense License Statement that
  41. you received with the Borland product to which this information
  42. pertains.
  43.