How do I get system info in Delphi
To get system information in Delphi, you can use the TOSVersion and TWindowsVersion classes from the Delphi RTL. These classes provide properties and methods that allow you to access various details about the operating system and the hardware running on your computer, such as the version number, build number, architecture, and processor type.
Here is an example of how you can use the TOSVersion and TWindowsVersion classes in Delphi to get system information
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 |
uses System.SysUtils, System.Win.Registry, Winapi.Windows; var OSVersion TOSVersion; WindowsVersion TWindowsVersion; ProcessorType Cardinal; begin Get the operating system version OSVersion = TOSVersion.Create; try Writeln(‘OS Name ‘, OSVersion.Name); Writeln(‘OS Version ‘, OSVersion.Major, ‘.’, OSVersion.Minor, ‘.’, OSVersion.Build); Writeln(‘OS Architecture ‘, OSVersion.Architecture); finally OSVersion.Free; end; Get the Windows version WindowsVersion = TWindowsVersion.Create; try Writeln(‘Windows Version ‘, WindowsVersion.VersionString); Writeln(‘Windows Build ‘, WindowsVersion.Build); Writeln(‘Windows Architecture ‘, WindowsVersion.Architecture); finally WindowsVersion.Free; end; Get the processor type if TRegistry.IsAvailable then begin with TRegistry.Create do try if OpenKeyReadOnly(‘HARDWAREDESCRIPTION/System/Central/Processor0’) then if ValueExists(‘Identifier’) then Writeln(‘Processor Type ‘, ReadString(‘Identifier’)); finally Free; end; end; end. |
This code sample uses the TOSVersion and TWindowsVersion classes to get the operating system and Windows version, as well as the processor type. You can use these classes to access other system information as well, such as the memory size, screen resolution, and available disk space. For more information, please refer to the Delphi documentation and the TOSVersion and TWindowsVersion class references.
Leave a Reply