/
RunAs.pas
112 lines (96 loc) · 3.11 KB
/
RunAs.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
{
Copyright (C) 2006-2008 Matteo Salvi of SalvadorSoftware
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
}
unit RunAs;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, VirtualTrees;
type
TfrmRunAs = class(TForm)
Panel1: TPanel;
lbUsername: TLabel;
lbPassword: TLabel;
edtUsername: TEdit;
edtPassword: TEdit;
btnOk: TButton;
btnCancel: TButton;
procedure TranslateForm(Lingua:string);
procedure btnCancelClick(Sender: TObject);
procedure btnOkClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmRunAs: TfrmRunAs;
implementation
uses Main, CommonUtils;
{$R *.dfm}
procedure TfrmRunAs.TranslateForm(Lingua:string);
begin
with frmMain.xmldTranslate.DocumentElement.ChildNodes['Form11'] do
begin
Caption := ChildNodes['Form11Caption'].Text;
lbUsername.Caption := ChildNodes['LabelUsername'].Text;
lbPassword.Caption := ChildNodes['LabelPassword'].Text;
btnOk.Caption := ChildNodes['ButtonOk'].Text;
btnCancel.Caption := ChildNodes['ButtonCancel'].Text;
end;
end;
procedure TfrmRunAs.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure TfrmRunAs.btnOkClick(Sender: TObject);
var
Tree : TBaseVirtualTree;
NodeDataList : PTreeData;
Node : PVirtualNode;
begin
if frmMain.pcList.ActivePageIndex = 0 then
Tree := frmMain.vstList
else
Tree := frmMain.vstSearch;
Node := Tree.GetFirstSelected;
while Assigned(Node) do
begin
if (Tree = frmMain.vstList) then
NodeDataList := frmMain.vstList.GetNodeData(Node)
else
NodeDataList := NodeDataXToNodeDataList(Node);
if Assigned(NodeDataList) then
begin
//Run file
if (NodeDataList.Tipo = 1) or (NodeDataList.Tipo = 2) then
begin
RunProcessAsUser(frmMain.vstList,NodeDataList,edtUsername.Text,edtPassword.Text);
AddMRU(frmMain.vstList,frmMain.CoolTrayIcon1,NodeDataList.pNode,NodeDataList.DontInsertMRU);
RunActionOnExe(NodeDataList);
end;
end;
if Node <> Tree.GetNextSelected(node) then
Node := Tree.GetNextSelected(node)
else
Node := nil;
end;
close;
end;
procedure TfrmRunAs.FormCreate(Sender: TObject);
begin
TranslateForm(LauncherOptions.LangName);
end;
end.