API Delphi

procedure TForm1.FormCreate(Sender: TObject);
var
iHandle:Hwnd;
begin
Application.Title:='Temp'; //sets your application title to temp
//looks for a pervious copy is running or not
iHandle:=Findwindow(pchar('TApplication'),pchar('One Copy'));
if iHandle>0 then begin // if found then display message
messagedlg('You can only have one copy of this application running on a PC!',mterror,[mbok],0);
application.Terminate; //terminates application
exit;
end;
//sets back to the current application title;
Application.Title:='One Copy';
end;