forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompTypes.pas
82 lines (69 loc) · 1.71 KB
/
CompTypes.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
unit CompTypes;
{
Inno Setup
Copyright (C) 1997-2014 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Types and functions used by both IDE and ISCC units
}
interface
uses
Windows, SysUtils, Registry, Classes;
type
TConfigIniFile = class(TRegIniFile)
private
FMutex: THandle;
FAcquiredMutex: Boolean;
public
constructor Create;
destructor Destroy; override;
end;
procedure ReadSignTools(SignTools: TStringList);
function AddSignToolParam(Sign: string): string;
implementation
procedure ReadSignTools(SignTools: TStringList);
var
Ini: TConfigIniFile;
I: Integer;
S: String;
begin
Ini := TConfigIniFile.Create;
try
{ Sign tools }
SignTools.Clear();
I := 0;
repeat
S := Ini.ReadString('SignTools', 'SignTool' + IntToStr(I), '');
if S <> '' then
SignTools.Add(S);
Inc(I);
until S = '';
finally
Ini.Free;
end;
end;
function AddSignToolParam(Sign: string): string;
begin
Result := 'SignTool-' + Sign + #0;
end;
{ 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.