-
Notifications
You must be signed in to change notification settings - Fork 64
/
DN.BPLService.Registry.pas
63 lines (53 loc) · 1.25 KB
/
DN.BPLService.Registry.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
unit DN.BPLService.Registry;
interface
uses
Registry,
DN.BPLService.Intf;
type
TDNRegistryBPLService = class(TInterfacedObject, IDNBPLService)
private
FRegistry: TRegistry;
FKey: string;
public
constructor Create(const ARootKey: string);
function Install(const ABPLFile: string): Boolean;
function Uninstall(const ABPLFile: string): Boolean;
end;
implementation
uses
Windows,
IOUtils;
{ TDNRegistryBPLService }
constructor TDNRegistryBPLService.Create(const ARootKey: string);
begin
inherited Create();
FKey := TPath.Combine(ARootKey, 'Known Packages');
FRegistry := TRegistry.Create();
FRegistry.RootKey := HKEY_CURRENT_USER;
FRegistry.Access := FRegistry.Access or KEY_WOW64_64KEY;
end;
function TDNRegistryBPLService.Install(const ABPLFile: string): Boolean;
begin
Result := FRegistry.OpenKey(FKey, True);
if Result then
begin
try
FRegistry.WriteString(ABPLFile, '');
finally
FRegistry.CloseKey();
end;
end;
end;
function TDNRegistryBPLService.Uninstall(const ABPLFile: string): Boolean;
begin
Result := FRegistry.OpenKey(FKey, False);
if Result then
begin
try
Result := FRegistry.DeleteValue(ABPLFile);
finally
FRegistry.CloseKey();
end;
end;
end;
end.