-
Notifications
You must be signed in to change notification settings - Fork 64
/
DN.BPLService.ToolsApi.pas
71 lines (62 loc) · 1.54 KB
/
DN.BPLService.ToolsApi.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
unit DN.BPLService.ToolsApi;
interface
uses
DN.BPLService.Intf;
type
TDNToolsApiBPLService = class(TInterfacedObject, IDNBPLService)
public
function Install(const ABPLFile: string): Boolean;
function Uninstall(const ABPLFile: string): Boolean;
end;
implementation
uses
Classes,
SysUtils,
ToolsApi;
{ TDNToolsApiBPLService }
function TDNToolsApiBPLService.Install(const ABPLFile: string): Boolean;
var
LResult: Boolean;
begin
LResult := False;
TThread.Synchronize(nil,
procedure
begin
LResult := (BorlandIDEServices as IOTAPackageServices).InstallPackage(ABPLFile);
end);
Result := LResult;
end;
function TDNToolsApiBPLService.Uninstall(const ABPLFile: string): Boolean;
var
LResult: Boolean;
LPackage: string;
LService: IOTAPackageServices;
begin
LResult := False;
TThread.Synchronize(nil,
procedure
var
i: Integer;
begin
LService := (BorlandIDEServices as IOTAPackageServices);
LResult := LService.UninstallPackage(ABPLFile);
if not LResult then
begin
//if uninstallation failed but package is not present, it is a doubled uninstallation
//we return success since this state might be archieved by a previous broken uninstallation
//or user manipulation
LResult := True;
LPackage := ExtractFileName(ABPLFile);
for i := 0 to LService.PackageCount - 1 do
begin
if SameText(LService.Package[i].Name, LPackage) then
begin
LResult := False;
Exit;
end;
end;
end;
end);
Result := LResult;
end;
end.