System Information Unit
ReadMe

Contents

This document applies to System Information Unit v5.4.0 and later.

» Contents

Description

This unit contains a group of static classes and some global variables that provide information about the user's computer system and operating system. Some useful constants and type definitions are also included. The static classes are:

In addition, the unit extends and enhances the information provided by the SysUtils unit's Win32xxx variables (such as Win32Platform) by defining further Win32xxx variables that store the extended operating system information available on later NT platform OSs.

Effect of changes to the Windows API

With the release of Windows 8.1 Microsoft made a controversial decision to deprecate the GetVersion*** API functions. These have always been used by the System Information Unit to get OS information. A new method of checking operating system version was recommended using the VerifyVersionInfo API. Unbelievably, this API itself became deprecated in Windows 10, but no viable alternative was introduced. In fact the Windows 10 SDK still uses the newly deprecated API!

If the old GetVersion*** approach is used Windows 8.1 represents itself as Windows 8 unless the host program has a special manifest. Using the VerifyVersionInfo API gets round that problem and Windows 8.1 reports itself as the correct version.

For this reason release 5 of the System Information Unit was revised to use the VerifyVersionInfo API for Windows 8.1 and later while retaining the GetVersion*** API for Windows 8 and earlier.

With Windows 10, the now deprecated VerifyVersionInfo API only reports Windows 10 correctly if the host program is manifested correctly. If there is no suitable manifest then Windows 10 reports itself as Windows 8, regardless of the API used. Believe it or not, this behaviour is as designed by Microsoft.

Unfortunately, the decision made in release 5.0 of the PJSysInfo unit to apply the VerifyVersionInfo only to Windows 8.1 and later results in un-manifested applications running on Windows 10 reporting Windows 7 instead of Windows 8 as documented by Microsoft. To fix this problem the VerifyVersionInfo API is now also used when running on Windows 8.

Apart from being more cumbersome and slower, the VerifyVersionInfo API approach differs from the old approach in an important respect. When a program is run in compatibility mode the old GetVersion*** API functions would be fooled (or"spoofed") by Windows into reporting the version of the operating system emulated by the compatibility mode (more or less!). This is the way the unit has always behaved in the past. The new approach used for Windows 8.1 introduced in v5.0 of this unit always returns information about the true operating system regardless of any active compatibility mode. As noted above, when adding support for Windows 10, in version 5.1, the use of VerifyVersionInfo was extended to Windows 8, meaning that now Windows 8, 8.1 and 10 cannot be spoofed. This is a change to the behaviour of v5.0 for Windows 8, meaning some code that depended on being able to spoof Windows 8 may no longer work.

To make things easier for Windows 2000 and later users (i.e. just about everyone) a bunch of interrogation functions that can't be spoofed have been added to TPJOSInfo. You can also find out if OS spoofing is enabled for the host operating system by examining the CanSpoof method of TPJOSInfo.

In summary, we have several inconsistencies in TPJOSInfo all because of some incomprehensible decisions made by Microsoft. They are:

After exploring and testing a lot of options this really is the best solution I can find. Thanks a bundle Microsoft!

To add insult to injury when Microsoft released the Windows 10 "November Update" (TH2) – a.k.a "Version 1511" they bumped the OS's build number but didn't update the service pack version information. Therefore existing code didn't report the update other than via the build number. I didn't want to break the existing TPJOSInfo.ServicePack method by pretending that TH2 was really a service pack, so I added a new ServicePackEx method to report any offical services packs and any significant updates that don't declare themselves as service packs. Ho hum!

Sorry that this is all so complicated - but it's complicated!!

Debug Mode

To enable the new Windows 8 and later OS information detection code to be debugged on Windows Vista and Windows 7, developers can temporarily define the DEBUG_NEW_API symbol. This causes the same method used for Windows 8 and later detection to used for Windows Vista and Windows 7.

To help with debugging developers can also define the DEBUG symbol. Range checking is forced on when DEBUG is defined.

Deleted Code

Version 2 and earlier of the unit provided the TPJSysInfo component and various SIGetxxx functions. As of v3.0 these were deprecated and finally removed at v4.0.

Compatibility

This unit is designed for compilation with the 32 bit and 64 bit Windows Delphi compilers. It has been tested with Delphi XE and XE4 only. An attempt has been made to retain compatibility back to Delphi 4, but this has not been tested.

Compilation on old Delphi versions that do not support setting registry access flags via TRegistry is not recommended since parts of the code may not work correctly on 64 bit Windows. Use of Delphi 6 or later is strongly recommended.

The unit not compatible with .NET.

The unit should operate correctly on the following platforms:

Operation on a 64 bit OS was last tested with Windows 10. Other OSs have not been tested.

The code is not suitable for non-Windows operating systems since it depends on the Windows API.

» Contents

Installation

The System Information Unit and demo programs are supplied in a zip file. Before installing you need to extract all the files, preserving the directory structure. The following files will be extracted:

In addition to the above files you will find the source code of two demo projects and their read-me file in the Demos directory.

There are three possible ways to use the unit.

  1. The simplest way is to add PJSysInfo.pas to your projects as you need it.
  2. To make the unit easier to re-use you can either copy it to a folder on your Delphi search path, or add the folder where you extracted the unit to the search path. You then simply use the unit as required without needing to add it to your project.
  3. For maximum portability you can add the unit to a Delphi package.

» Contents

Documentation

The System Information Unit is fully documented online.

There is no help file.

» Contents

Demo Projects

Two demo projects are included in the download in the Demos\VCL and the Demos\FMX directories. The former compiles to a VCL application using Delphi XE (and possibly even Delphi 4) or later while the latter uses the FireMonkey 2 framework and requires Delphi XE3 as a minimum. Both projects can be compiled to either Windows 32 bit or 64 bit targets.

Each project contains a tab set where each tab displays the information from one of the classes or the global variables.

» Contents

Update History

A complete change log is provided in a text file that is included in the download.

Acknowledgements

Information from numerous websites has been used while developing this code. Several individuals have also suggested solutions or contributed code.

Full details are provided in the file Acknowledgements.md in the projects\sysinfo\Docs subdirectory of the System Information Unit's Subversion repository trunk.

» Contents

License

The System Information Unit is released under the terms of the Mozilla Public License, v2.0.

» Contents

Bugs and Feature Requests

Bugs can be reported or new features requested via the Issue Tracker.

First review any open tickets to check if a similar report has been made. If so please add any information you can as a comment rather than creating a new ticket. If there's no similar report you should create a new ticket using the Create Ticket button.

Fill out the resulting form providing as much information as possible. Because the ticketing system is used for all DelphiDabbler Code Library projects you need to identify this project by entering sysinfo in the Project edit box. To report a bug choose Defect from the Type edit box or select Enhancement if you are suggesting a new feature.

» Contents

About the Author

I'm Peter Johnson (@delphidabbler) – a hobbyist programmer living in Ceredigion in West Wales, UK, writing write mainly in Delphi.

Please use the Issue Tracker noted above to report bugs and request new features.