12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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.
|