unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Windows10, StdCtrls, Registry;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    ResultMemo: TMemo;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    Procedure Print(str: string);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

Procedure TForm1.Print(str: string);
begin
 ResultMemo.Lines.Add(str);
end;

procedure TForm1.Button1Click(Sender: TObject);
//Var
// Reg: TRegistry;
begin

 ResultMemo.Lines.Clear;
{
 ResultMemo.Lines.Add('Creating TRegistry...');
 Reg := TRegistry.Create;
 ResultMemo.Lines.Add('Setting RootKey To HKEY_LOCAL_MACHINE...');
 Reg.RootKey := HKEY_LOCAL_MACHINE;
 Try
  ResultMemo.Lines.Add('Opening Key [\SOFTWARE\The CoolMon Project] with CanCreate = True...');
  Reg.OpenKey('\SOFTWARE\The CoolMon Project', true);
  ResultMemo.Lines.Add('Writing StringValue "ElevationTest"...');
  Reg.WriteString('ElevationTest', 'If You Can Read This, There Was Admin Access');
  ResultMemo.Lines.Add('Done');
 Except
  on E : Exception do begin
   ResultMemo.Lines.Add('Exception class name = '+E.ClassName);
   ResultMemo.Lines.Add('Exception message = '+E.Message);
  end;
 end;

 Reg.Free;
}
 If HasAdminAccess then Print('Admin Access')
  else Print('Access Denied');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 RunAsAdmin(Application.Handle, ParamStr(0), '');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
 ShellExecutionAsAdmin(ParamStr(0));
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
 RestartApplicationWithElevatedPriviliges;
end;

procedure TForm1.Button5Click(Sender: TObject);
var
 WinVer: TWinVer;
begin
 ResultMemo.Clear;

 WinVer := TWinVer.Create;
 Print('Brand Name: ' + WinVer.BrandName);
 Print('Version String: ' + WinVer.WinVersionString);
 Print('Major: ' + IntToStr(WinVer.MajorVersion));
 Print('Minor: ' + IntToStr(WinVer.MinorVersion));
 Print('Build: ' + IntToStr(WinVer.BuildVersion));
 Print('Platform: ' + IntToStr(WinVer.PlatForm));

 WinVer.Free;
end;

end.
