We use the folowing

function AmITheOnlyOne : Boolean;
file://Returns true if the system is the only one
var
   zAppName  : array[0..260] of char;
begin
 Result := True;
 {copy the current app's title to a null terminated string}
   StrPCopy(zAppName, Application.Title);

   {see if the named mutex object existed before this call}
  MutexHandle := CreateMutex(nil, TRUE, zAppName);
  if MutexHandle <> 0 then begin
     if GetLastError = ERROR_ALREADY_EXISTS then begin
      CloseHandle(MutexHandle);
         Result := False;
        end;
 end;
end;



Rob
Software engineer
Wild Software Ltd
[EMAIL PROTECTED]
----- 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
>
>
> ######################################################################
> Attention:
> The information in this email and in any attachments is confidential.
> If you are not the intended recipient then please do not distribute,
> copy or use this information. Please notify us immediately by return
> email and then delete the message from your computer.
> Any views or opinions presented are solely those of the author.
> ######################################################################
> --------------------------------------------------------------------------
-
>     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"
>

---------------------------------------------------------------------------
    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"

Reply via email to