Inno-Setup-issrc/Projects/Src/Shared.ConfigIniFile.pas

53 lines
1.1 KiB
ObjectPascal
Raw Permalink Normal View History

2024-08-04 21:32:25 +02:00
unit Shared.ConfigIniFile;
2014-05-27 15:06:41 +02:00
{
Inno Setup
2024-08-04 21:32:25 +02:00
Copyright (C) 1997-2024 Jordan Russell
2014-05-27 15:06:41 +02:00
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
2024-08-04 21:32:25 +02:00
ConfigIniFile class used by both IDE and ISCC units
2014-05-27 15:06:41 +02:00
}
interface
uses
2024-08-04 21:32:25 +02:00
Windows, Registry;
2014-05-27 15:06:41 +02:00
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.