Einzelnen Beitrag anzeigen

Relicted

Registriert seit: 24. Jan 2006
Ort: Iserlohn
646 Beiträge
 
Delphi 10.4 Sydney
 
#2

Re: HPrevInst ist veraltet - wie besser

  Alt 29. Jul 2008, 10:15
Zitat:
HPrevInst exists in all Delphi versions, but is only useful in a 16-bit application. It gives the instance handle of the previous running instance of your application. If it is non-zero, then you are not the first instance of your application.
Zitat:
HPrevInst
Cannot be tested for multiple instances in Win32
Ich gehe davon aus dass du beim Start prüfst ob schon einmal dein Programm gestartet ist.. Rüchtig?

Wenn ja dann hier weiterlesen, wenn nicht

Delphi-Quellcode:
var
 hMutex : cardinal;
begin
  // Prüfen ob das Programm schon mal gestartet ist!
  hMutex := CreateMutex( nil, // pointer to security attributes
                         True, // flag for initial ownership
                         'appname' ); // pointer to mutex-object name
  if ( GetLastError = ERROR_ALREADY_EXISTS ) then
  begin
    if ( hMutex <> 0 ) then
      CloseHandle( hMutex );
    Exit;
  end;
end.

Gruß
Reli
  Mit Zitat antworten Zitat