Another way:
var atom : word; //global
procedure TForm1.OnCreate(sender : Tobject);
begin
if GlobalFindAtom('PROGRAM_RUNNING')=0 then
begin
atom := GlobalAddAtom('PROGRAM_RUNNING');
end else
begin
MessageDlg('Program is already Running', mtWarning, [mbOK], 0 );
Halt;
end;
end;
procedure TForm1.OnDestroy(sender : Tobject);
begin
GlobalDeleteAtom(atom);
end;
Patrick Sheehan
----- Original Message -----
From: "Colin Fraser" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Tuesday, June 19, 2001 4:38 PM
Subject: [DUG]: Run Once Code
> Hi,
>
> Does anyone have handy any code that will stop an application running more
> than once instance...
>
> I know there are some components around that you can just dump on the main
> form, but what I am after is to programmatically control how the app
starts.
>
> For example, if there is a certain command line parameter then start a new
> instance, otherwise bring the new instance to the front and process the
new
> command line parameters.
>
> Regards
>
> Colin
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"