Ver Mensaje Individual
  #2  
Antiguo 31-07-2023
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.735
Reputación: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Parece que no liberas el Mutex.
Quizás se crea el mutex, pero da error porque ya existe y luego no se libera.
Yo siempre tengo el create seguido de try..finally. Dentro de esto el resto de la programación.
De esta manera evito la posibilidad de que no se libere por alguna condición escondida en la programación.

Código Delphi [-]
  o := TComponente.Create();
  try
    // Trabajar con o
    ...
  finally
    o.Free;
  end;


Código Delphi [-]
var
  IniAux: TIniFile;
  Mutex : THandle;
begin
  Mutex := CreateMutex(nil, True, 'GemaExclusiveMutex');
  try
    if (Mutex <> 0) And (Windows.GetLastError =  0) then
    begin
      with Application do
      begin
        if (ShortDateFormat = 'M/d/yyyy') then
        begin
          ShortDateFormat:='MM/dd/yyyy';
        end;
        // showMessage('');        <--- si pongo el showmessage aqui es cuando funciona
        CreateForm(TDMFJoya, DMFJoya);
        CreateForm(TDM, DM);
        CreateForm(TFMain, FMain);
        if FMain.bErrorGrave then Exit;
        FMain.Visible := False;
        FMain.Show;
        if not FMain.bModoAutomatico then
        begin
          FMain.WmAfterCreate;
        end;

        Run;
      end;
      DMFJoya.Free();
      IniAux.Free;
    end
    else
    ShowMessage('La aplicación ya está en ejecución');
  finally
    if Mutex <> 0 then
      CloseHandle(Mutex);
  end;
end;
Responder Con Cita