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:
Provides information about the host computer and current user.
Gets the full path of certain system folders.
Supplies information about the operating system including the platform, product name, product ID, version and service packs.
In addition, the unit extends 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.
Compatibility Mode Issues
With the introduction of Windows 8.1 Microsoft deprecated the GetVersion and GetVersionEx API functions that PJSysInfo uses to get operating system version information. These API functions always return information about the reported operating system, which, when the program is running in compatibility mode, may be different to the true operating system. Furthermore GetVersion will not detect Windows 8.1 correctly in all cases.
From version 5 of the unit, to avoid using the deprecated API functions, a different approach is used to obtain version information when running on Windows 8.1 or later. This new method always returns information about the true operating system, regardless of any compatibility mode.
These changes mean that some of TPJOSInfo's methods and some global variables are affected by compatibility mode when run on operating systems prior to Windows 8.1, but will ignore compatibility mode on Windows 8.1 and later.
To help decide if compatibility mode will affect the returned information the TPJOSInfo.CanSpoof method was added in v5.0.
It is unfortunate that the class's behaviour is no longer consistent across operating systems, but there is no choice if the code is to abide by Microsoft's much criticised decision to deprecate and possibly remove the old API.
v5.0 also adds some new methods to TPJOSInfo that can be used to detect operating systems that always ignore compatibility mode – i.e. they can't be spoofed.
In summary, there are several inconsistencies in TPJOSInfo all because of some incomprehensible decisions made by Microsoft. They are:
On OSs up to and including Windows 7 SP 1 the reported operating system can be "spoofed" by setting the host program's compatibility mode. The exception is that the TPJOSInfo.IsReallyWindowsXXXOrGreater methods for Windows 2000 and later will detect the actual operating system.
For Windows 8 and 8.1 the reported operating system cannot be spoofed using compatibility modes, and neither does the presence of a suitable manifest file affect the returned values. This also applies to the relevant TPJOSInfo.IsReallyWindowsXXXOrGreater methods.
For Windows 10 the reported operating system cannot be spoofed regardless of whether a suitable manifest is compiled into resource. However, in absence of a such a manifest the version will be always be reported as Windows 8 instead of Windows 10. This also affects TPJOSInfo.IsReallyWindows10OrGreater, meaning it's not so well named any more!
After exploring and testing a lot of options this really is the best solution I can find. Thanks a bundle Microsoft!
For the final word on this, see the project documentation.
Registry Issues With Old Delphis
The stated compatibilty for the unit is Delphi 7 & later. However it is possible that the unit may compile with earlier versions.
But be warned, there is a known issue with some of these old versions in that they do not support setting registry access flags via the TRegistry object. This means that some of this code may not work correctly when running 32 bit programs on 64 bit Windows.
Consequently, using Delphi 6 or earlier is not recommended and is not supported.
Version 2 and earlier of the unit provided the TPJSysInfo component and various SIGetxxx functions. As of v3.0 these were deprecated and included only if a certain symbol was defined. From v4.0 all the deprecated code was removed.
If you are still using the deprecated code you need to update your code to use the new classes.
Two demo projects are included in the download in the
Demos\VCL and the
Demos\FMX directories. The former compiles to a VCL application 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.
The VCL demo has been tested with Delphi XE and XE4 but should compile with Delphi 7 or later, although some unrecognised form properties may need to be ignored. The FireMonkey demo was tested with Delphi XE4.