// Mit dem folgenden Code (im Quelltext des Projekts) kann man // steuern, wie oft das Programm gleichzeitig geöffnet werden // darf. Im Beispiel kann das Programm kein viertes mal geöffnet // werden, wenn es bereits dreimal nebeneinander läuft. // Siehe auch: Programm nur 1x starten // Getestet mit D4 unter NT program Project1; uses Forms, Windows, Unit1 in 'Unit1.pas' {Form1}; {$R *.RES} var H: THandle; const Anzahl: Cardinal = 3; begin H := createSemaphore(nil, Anzahl, Anzahl, 'My_Semaphore_Test'); if H > 0 then begin if WaitForSingleObject(H, 0) = WAIT_OBJECT_0 then begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; ReleaseSemaphore(H, 1, nil); end; end; end. |