Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Programm nur einmal starten (https://www.delphipraxis.net/61713-programm-nur-einmal-starten.html)

ghost007 25. Jan 2006 14:02


Programm nur einmal starten
 
Hallo,
wie kann ich machen, das man meine programm nur einmal starten kann? also man soll niemals 2 oder mehr parallel laufen lassen können.

Bernhard Geyer 25. Jan 2006 14:04

Re: Programm nur einmal starten
 
Such mal nach Hier im Forum suchenSEMAPHORE. Frage wurde schon öfter gestellt.

inherited 25. Jan 2006 14:07

Re: Programm nur einmal starten
 
Delphi-Quellcode:
unit NichtDoppeltStarten;

interface

implementation

uses windows,Dialogs,sysutils;

var mHandle: THandle;   // Mutexhandle

Initialization
  mHandle := CreateMutex(nil,True,'xxxxx');
  // 'xxxxx' Der Anwendungsname ist hier einzutragen
  if GetLastError = ERROR_ALREADY_EXISTS then begin  
    showMessage('Anwendung läuft bereits!!!!!');  
    // Wenn du keine Meldung willst, Auskommentieren
    Halt;
  end;

finalization  // ... und Schluß
  if mHandle <> 0 then
    CloseHandle(mHandle)
end.

ils566 3. Feb 2006 08:22

Re: Programm nur einmal starten
 
Liste der Anhänge anzeigen (Anzahl: 1)
z.B. mit der beigefügten Unit. Funktioniert auf jeden Fall mit D6/D7 und W2K.
Gruß
ils


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz