Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi HPrevInst ist veraltet - wie besser (https://www.delphipraxis.net/117967-hprevinst-ist-veraltet-wie-besser.html)

Cappuccino 29. Jul 2008 09:16


HPrevInst ist veraltet - wie besser
 
Hallo,
HPrevInst wird in D2007 als deprecated angegeben.
Weiß jemand, wie die Abfrage aktuell aussehen muss.

Danke +
Gruß
Tom

Relicted 29. Jul 2008 10:15

Re: HPrevInst ist veraltet - wie besser
 
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 :glaskugel: :-)

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

Cappuccino 29. Jul 2008 10:27

Re: HPrevInst ist veraltet - wie besser
 
Danke,
es wird geprüft, ob die Fensterklasse existiert.
Das werde ich dann über den Mutex prüfen.

Gruß
Tom


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:28 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