Examples Delphi

-operating system
function GetOS: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('software\microsoft\windows\currentversion', False);
Result := reg.ReadString('ProductName');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.caption := GetOS;
end;
----------------------------------------------------------------------
-Version
function GetWindowsVer: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('software\microsoft\windows\currentversion', False);
Result := reg.ReadString('Version');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.caption := GetWindowsVer;
end;
----------------------------------------------------------------------
-version number
function GetWindowsVerNo: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('software\microsoft\windows\currentversion', False);
Result := reg.ReadString('VersionNumber');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.caption := GetWindowsVerNo;
end;
----------------------------------------------------------------------
-product key
function GetWindowsKey: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('software\microsoft\windows\currentversion', False);
Result := reg.ReadString('ProductKey');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.caption := GetWindowsKey;
end;
----------------------------------------------------------------------
-direct x version
function GetDirectxVer: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('software\microsoft\DirectX', False);
Result := reg.ReadString('Version');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.caption := GetDirectxVer;
end;
---------------------------------------------------------------------
-Current time
function GetLocalT: String;
var
stSystemTime : TSystemTime;
begin
Windows.GetLocalTime( stSystemTime );
Result := DateTimeToStr( SystemTimeToDateTime( stSystemTime ) );
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=GetLocalT;
end;
---------------------------------------------------