System info

Delphi version value list table

Posted in System info

 

The CompilerVersion constant identifies the internal version number of the Delphi compiler. It is defined in the System unit and may be referenced either in code just as any other constant:

if CompilerVersion = 20 then

   sCompilerName := 'Delphi 2009';

 

or in conditional compiler expressions:

 {$if CompilerVersion > 18} // Delphi 2007 or later

{$ifend}

 

 

Technical Comments

The CompilerVersion constant was introduced in Delphi 6 along with conditional expressions. In earlier Delphi versions various compiler defined VERxxx symbols are used to determine compiler versions.

 

CompilerVersion values and the equivalent compiler defined symbols for the Delphi versions in which the CompilerVersion constant is defined are:

CompilerCompilerVersion

Defined Symbol

Delphi 10.2 Tokyo 32 VER320
Delphi 10.1 Berlin 31 VER310
Delphi 10 Seattle 30 VER300
Delphi XE8 29 VER290
Delphi XE7 28 VER280
Delphi XE6 27 VER270
AppMethod 1 26.5 VER265
Delphi XE5 26 VER260
Delphi XE4 25 VER250
Delphi XE3 24 VER240
Delphi XE2 23 VER230
Delphi XE 22 VER220
Delphi 2010 21 VER210
Delphi 2009 20 VER200
Delphi 2007 .NET 19 VER190
Delphi 2007 18.5 VER185 (also VER180)
Delphi 2006 18 VER180
Delphi 2005 17 VER170
Delphi 8 .NET 16 VER160
Delphi 7 15 VER150
Delphi 6 14 VER140
Delphi 5 13(*) VER130
Delphi 4 12(*) VER120
Delphi 3 10(*) VER100
Delphi 2 9(*) VER90
Delphi 1 8(*) VER80

Set the system time and date

Posted in System info

Use SystemTime structure for changing system date and time, and then use SetSystemTime procedure to set them into the system.

procedure TForm1.Button1Click(Sender: TObject);
var
  dt: TSystemTime;
begin
  dt.wYear:=1999;
  dt.wMonth:=2;
  dt.wDay:=25;
  dt.wHour:=9;
  dt.wMinute:=0;
  dt.wSecond:=0;
  dt.wMilliseconds:=0;
  if SetSystemTime(dt) then Label1.Caption:='Setting finished';
end;

Search the boot drive

Posted in System info

Use "BootDir" value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup:

uses Registry;
...
procedure TForm1.Button1Click(Sender: TObject);
begin
  with TRegistry.Create do
  begin
    RootKey:=HKEY_LOCAL_MACHINE;
    if OpenKey(
      'Software\Microsoft\Windows\CurrentVersion\Setup', 
      False) then
    try
      Edit1.Text:=ReadString('BootDir');
    except
      MessageDlg('Can not go to this handle',mtError,[mbOk],0);
    end
    else
      MessageDlg('Error registry reading',mtError,[mbOk],0);
    CloseKey;
  end;
end;

Set resolution of screen

Posted in System info

Use ChangeDispleySettings function with TDeviceModeA structure for this problem.

procedure TForm1.Button1Click(Sender: TObject);
var
  MyMode: TDeviceModeA;
begin
  MyMode.dmSize:=Sizeof(MyMode);
  MyMode.dmFields:=DM_PELSWIDTH	and DM_PELSWIDTH;
  MyMode.dmPelsWidth:=StrToInt(Edit1.Text);
  MyMode.dmPelsHeight:=StrToInt(Edit2.Text);
  ChangeDisplaySettings(MyMode, 0);
end;

Get time zone information

Posted in System info

Use GetTimeZoneInformation function. TIME_ZONE_INFORMATION structure contains all information about time and zone.

procedure TForm1.Button1Click(Sender: TObject);
var
  ZoneInfo: TTimeZoneInformation;
begin
  GetTimeZoneInformation(ZoneInfo);
  with Memo1.Lines do
  begin
    Add('Bias: '+ IntToStr(ZoneInfo.Bias));
    Add('StandardName: '+ZoneInfo.StandardName);
    Add('StandardBias: '+IntToStr(ZoneInfo.StandardBias));
    Add('DaylightName: '+ZoneInfo.DaylightName);
    Add('DaylightBias: '+IntToStr(ZoneInfo.DaylightBias));
  end;
end;