Inno-Setup-issrc/Projects/Src/Shared.ConfigIniFile.pas
2024-08-04 21:32:25 +02:00

53 lines
1.1 KiB
ObjectPascal

unit Shared.ConfigIniFile;
{
Inno Setup
Copyright (C) 1997-2024 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
ConfigIniFile class used by both IDE and ISCC units
}
interface
uses
Windows, Registry;
type
TConfigIniFile = class(TRegIniFile)
private
FMutex: THandle;
FAcquiredMutex: Boolean;
public
constructor Create;
destructor Destroy; override;
end;
implementation
{ TConfigIniFile }
constructor TConfigIniFile.Create;
begin
inherited Create('Software\Jordan Russell\Inno Setup');
{ Paranoia: Use a mutex to prevent multiple instances from reading/writing
to the registry simultaneously }
FMutex := CreateMutex(nil, False, 'Inno-Setup-IDE-Config-Mutex');
if FMutex <> 0 then
if WaitForSingleObject(FMutex, INFINITE) <> WAIT_FAILED then
FAcquiredMutex := True;
end;
destructor TConfigIniFile.Destroy;
begin
if FMutex <> 0 then begin
if FAcquiredMutex then
ReleaseMutex(FMutex);
CloseHandle(FMutex);
end;
inherited;
end;
end.