Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Saber si la aplicación ya está en ejecución (https://www.clubdelphi.com/foros/showthread.php?t=80546)

Neftali [Germán.Estévez] 30-06-2006 13:01:41

Saber si la aplicación ya está en ejecución
 
¿Cómo puedo saber si mi aplicación ya se está ejecutando?

Código Delphi [-]
// mutex.dpr
program NombreAplicación;

uses Forms,Windows,Dialogs, form1 in 'form1.pas';

{$R *.RES}

const NombreMutex='Tu aplicación';

Var Mimutex:Thandle;

begin
  mimutex:= createmutex(nil,true,nombremutex);
  if mimutex=0 then begin
    Showmessage('Error creando mutex');
    halt;
  end;
  if getlasterror=ERROR_ALREADY_EXISTS then begin
    Showmessage('Ya está funcionando');
    halt;
  end;

  Application.initialize;

......createform

.......run

  closehandle(mimutex);

end.




La franja horaria es GMT +2. Ahora son las 14:16:08.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi