unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
WinApi.ShellAPI;
type
TForm1 =
class(TForm)
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure RunAsAdmin(hWnd: HWND; aFile:
string; aParameters:
string);
var sei: TShellExecuteInfo;
begin
FillChar(sei, SizeOf(sei), 0);
sei.cbSize := sizeof(sei);
sei.Wnd := hWnd;
sei.fMask := SEE_MASK_FLAG_DDEWAIT
or SEE_MASK_FLAG_NO_UI;
sei.lpVerb := '
runas';
sei.lpFile := PChar(aFile);
sei.lpParameters := PChar(aParameters);
sei.nShow := SW_HIDE;
// SW_SHOWNORMAL; SW_HIDE; SW_MAXIMIZE;
if not ShellExecuteEx(@sei)
then RaiseLastOSError;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if RadioButton1.Checked
then
RunAsAdmin(Application.Handle,'
BDS.exe', '
')
else
ShellExecute(Application.Handle,
NIL,'
BDS.exe','
',
NIL, SW_SHOW);;
end;
end.