.........
public
aa:word;
.........
procedure TForm1.FormCreate(Sender: TObject);
Begin
//Search the system database to see if the program is running
if GlobalFindAtom(''Project1'') =0 then // Project1 is the EXE file name
//If the EXE file is not found, add the EXE file name to the system database
aa := GlobalAddAtom('' Project1'')
else
begin //If the program is already running, display the information and exit the program
MessageDlg(''This program is running!'', mtWarning, [mbOK], 0);
Halt;
end;
end;
.........
procedure TForm1.FormDestroy(Sender: TObject);
Begin
{ When exiting the program, delete the added file name from the data table}
GlobalDeleteAtom(aa);
end;