Einzelnen Beitrag anzeigen

brechi

Registriert seit: 30. Jan 2004
823 Beiträge
 
#32

Re: Verhindern das die gleich Exe gestartet wird

  Alt 28. Nov 2005, 11:52
und mit dem mutex gehts so:

Delphi-Quellcode:
program Project2;

uses
  Forms,
  windows,
  Unit1 in 'Unit1.pas{Form1};

{$R *.res}

var mhandle,i: integer;
s: String;
begin
  s := paramstr(0);
  for i := 1 to length(s) do if s[i] = '\then s[i] := '-';
  mHandle := CreateMutex(nil, true, PChar(s));
  if (GetLastError = Error_Already_Exists) then halt;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
  if mHandle <> 0 then CloseHandle(mHandle);
end.
  Mit Zitat antworten Zitat