-
Notifications
You must be signed in to change notification settings - Fork 0
/
msi_unit.pas
119 lines (94 loc) · 2.77 KB
/
msi_unit.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
unit msi_unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, VirtualTrees, ExtCtrls, ShellApi, Menus, sEdit, sButton,
sLabel, sPanel;
type
Tmsi_form = class(TForm)
pnl1: TsPanel;
tree: TVirtualStringTree;
lbl1: TsLabel;
pnl2: TsPanel;
pnl3: TsPanel;
Panel1: TsPanel;
Label1: TsLabel;
pnl4: TsPanel;
btn1: TsButton;
pm1: TPopupMenu;
edt1: TsEdit;
Guid: TsLabel;
edt2: TsEdit;
lbl2: TsLabel;
btn2: TsButton;
procedure btn1Click(Sender: TObject);
procedure treeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
procedure btn2Click(Sender: TObject);
procedure treeFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
private
{ Private declarations }
public
{ Public declarations }
end;
PPackageRecord = ^TPackageRecord;
TPackageRecord = record
guid:string;
name:string;
end;
var
msi_form: Tmsi_form;
implementation
uses unit1, routine_strings, main;
{$R *.dfm}
procedure Tmsi_form.btn1Click(Sender: TObject);
var
products_list:TStringList;
data : PPackageRecord;
node : PVirtualNode;
guid : string;
i:Integer;
begin
ShellExecute( application.Handle, 'open', PWideChar( work_dir + '\getguids.vbs' ), nil, PWideChar( work_dir ), SW_SHOW );
products_list := TStringList.Create;
products_list.LoadFromFile( work_dir + '\productslist.txt' );
tree.NodeDataSize := SizeOf( TPackageRecord );
for i := 0 to products_list.Count - 1 do
begin
node := tree.AddChild( nil );
data := tree.GetNodeData( node );
PPackageRecord( data )^.guid := SubString( products_list.Strings[ i ], '}', 1 ) + '}';
PPackageRecord( data )^.name := SubString( products_list.Strings[ i ], '}', 2 );
end;
end;
procedure Tmsi_form.treeGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
var
Data: PPackageRecord;
begin
Data := Sender.GetNodeData( Node );
if Assigned( Data ) then
begin
if Column = 0 then
CellText := PPackageRecord( Data ).name;
if Column = 1 then
CellText := PPackageRecord( Data ).guid;
end;
end;
procedure Tmsi_form.btn2Click(Sender: TObject);
begin
Close;
end;
procedure Tmsi_form.treeFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
var
data : PPackageRecord;
begin
data := tree.GetNodeData( node );
edt1.Text := PPackageRecord( data ).guid;
edt2.Text := 'msiexec.exe /x ' + PPackageRecord( data ).guid + ' /qn';
end;
end.