Declare a global variable to your unit:
var atom : word;
on you mainforms OnCreate Event put this.....
procedure TForm1.OnCreate(sender : Tobject);
begin
if GlobalFindAtom('PROGRAM_RUNNING) = 0 then begin
{Search the global
atom table for the program thats running}
atom := GlobalAddAtom('PROGRAM_RUNNING');
{add it to the table if its not found}
end
else
begin
MessageDlg('Program is already Running!',mtWarning,[mbOK],0);
{if its found, show a
message}
Halt; {and halt the
running of another instance of the program}
end;
end;
And on the programs on destroy event
procedure TForm1.OnDestroy(Sender : TObject);
begin
GlobalDeleteAtom(atom); {remove it from the
global atom table}
end;
I have tried it and it works very well
Regards Tim Carthew