Solved

Killing Program/Process Before Shutdown

Posted on 1998-09-11
4
145 Views
Last Modified: 2010-04-06
I Need To Kill Program/Service/Process Before Win9x Shutdown....  how i do that using Delphi ?
i don't know much Delphi...
0
Comment
Question by:natanp
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
ID: 1339489
Here is an example........
---------
interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    function HookProc(var Message: TMessage): boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

const
  FlagFileName = 'C:\Flag.Fil';

procedure CreateFlagFile;
var
  F: System.Text;
begin
  System.Assign(F, FlagFileName);
  System.Rewrite(F);
  Writeln(F, 'This is a dummy flag file');
  System.Close(F);
end;

procedure KillFlagFile;
var
  F: File;
begin
  System.Assign(F, FlagFileName);
  System.Erase(F);
end;

procedure MyExitProc; far;
begin
  KillFlagFile;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.HookMainWindow(HookProc);
end;

function TForm1.HookProc(var Message: TMessage): boolean;
begin
  Result := false;
  if Message.Msg = WM_EndSession then
  begin
    if WordBool(Message.wParam) then
    begin
      { Windows is closing down - clean up!! }
       Halt;
    end;
  end;
end;

initialization
  CreateFlagFile;
  AddExitProc(MyExitProc);
end.
-----------
Regards,
Viktor Ivanov
0
 
LVL 7

Expert Comment

by:Motaz
ID: 1339490
When Windows 95 shut down it will shut all applications and process so that if you write Delphi program to detect windows shut down and close all other applications; it dosn't mean any thing becuase windows automaticly shut down this programs when it shut down.

Motaz from Sudan.
motaz1@yahoo.com
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339491
Natan maybe needs to clean up something when win shuts down...

//viktor
0
 
LVL 7

Expert Comment

by:Motaz
ID: 1339492
Yes, that is right viktornet.

Motaz.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

821 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