-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysinfo.html
275 lines (265 loc) · 14.2 KB
/
sysinfo.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
---
dl-file-prefix: "dd-sysinfo-"
layout: "codelib-tplt"
group: lib
priority: 11
version: "5.32.0"
release-date: "2025-04-02"
platforms: ["Win32", "Win64"]
frameworks: ["RTL"]
compatibility: "Delphi 7 & later"
title: "System Information Unit"
precis: "Gets information about the host computer and operating system"
summary: "Source code of a unit containing classes, constant, type definitions and routines to provide information about the host computer and operating system."
meta-title: "System Information Classes for Delphi Pascal | Open Source | 32 & 64 bit"
meta-desc: "A set of Delphi Pascal classes that provide information about the host computer & Windows version information and system folders. Requires Delphi 7 & later."
download-base-url: "https://sourceforge.net/projects/ddablib/files/sysinfo/"
repo-url: "https://github.com/ddablib/sysinfo"
docs-url: "https://lib-docs.delphidabbler.com/SysInfo/"
want-header-buttons: true
status: "current"
---
{% assign dl-file = page.dl-file-prefix | append: page.version | append: ".zip" %}
{% assign dl-url = page.download-base-url | append: dl-file %}
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Overview
</h2>
</div>
<div class="panel-body">
<p>
This unit contains a group of three static classes, one ordinary class 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 classes are:
</p>
<dl>
<dt>
TPJComputerInfo
</dt>
<dd>
Static class that provides information about the host computer and current user.
</dd>
<dt>
TPJSystemFolders
</dt>
<dd>
Static class that gets the full path of certain system folders.
</dd>
<dt>
TPJOSInfo
</dt>
<dd>
Static class that supplies information about the operating system including the platform, product name, product ID, version and service packs.
</dd>
<dt>
TPJBiosInfo
</dt>
<dd>
Class that provides information about the computer's BIOS.
</dd>
</dl>
<p>
In addition, the unit extends the information provided by the <code>SysUtils</code> unit's <var>Win32xxx</var> variables (such as <var>Win32Platform</var>) by defining further <var>Win32xxx</var> variables that store the extended operating system information available on later NT platform OSs.
</p>
<h3 data-toggle="collapse" data-target="#compat-mode" class="collapsible collapsed text-warning glyph">
Compatibility Mode Issues
</h3>
<div id="compat-mode" class="collapse callout callout-warning"> <!-- begin collapsible #compat-mode section -->
<p>
With the introduction of Windows 8.1 Microsoft deprecated the <var>GetVersion</var> and <var>GetVersionEx</var> API functions that <var>PJSysInfo</var> 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 <var>GetVersion</var> will not detect Windows 8.1 correctly in all cases.
</p>
<p>
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.
</p>
<p>
These changes mean that some of <var>TPJOSInfo</var>'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.
</p>
<p>
To help decide if compatibility mode will affect the returned information the <var>TPJOSInfo.CanSpoof</var> method was added in v5.0.
</p>
<p>
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.
</p>
<p>
v5.0 also adds some new methods to <var>TPJOSInfo</var> that can be used to detect operating systems that always ignore compatibility mode – i.e. they can't be spoofed.
</p>
<p>
In summary, there are several inconsistencies in <var>TPJOSInfo</var> all because of some incomprehensible decisions made by Microsoft. They are:
</p>
<ul>
<li>
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 <var>TPJOSInfo.IsReallyWindowsXXXOrGreater</var> methods for Windows 2000 and later will detect the actual operating system.
</li>
<li>
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 <var>TPJOSInfo.IsReallyWindowsXXXOrGreater</var> methods.
</li>
<li>
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 <var>TPJOSInfo.IsReallyWindows10OrGreater</var>, meaning it's not so well named any more!
</li>
</ul>
<p>
After exploring and testing a lot of options this really is the best solution I can find. Thanks a bundle Microsoft!
</p>
<p>
For the final word on this, see the <a href="https://github.com/delphidabbler/ddab-lib-docs/blob/master/Docs/SystemInformationUnit.md">project documentation</a>.
</p>
</div> <!-- /#compat-mode -->
<h3 data-toggle="collapse" data-target="#registry" class="collapsible collapsed text-warning glyph">
Registry Issues With Old Delphis
</h3>
<div id="registry" class="collapse callout callout-warning"> <!-- begin collapsible #registry section -->
<p>
The stated compatibilty for the unit is Delphi 7 & later. However it is possible that the unit may compile with earlier versions.
</p>
<p>
<strong>But be warned,</strong> there is a known issue with some of these old versions in that they do not support setting registry access flags via the <var>TRegistry</var> object. This means that some of this code may not work correctly when running 32 bit programs on 64 bit Windows.
</p>
<p class="text-warning bg-warning">
Consequently, using Delphi 6 or earlier is not recommended and is not supported.
</p>
</div> <!-- /#registry -->
<h3 data-toggle="collapse" data-target="#deleted-code" class="collapsible collapsed text-danger glyph">
Deleted Code
</h3>
<div id="deleted-code" class="collapse callout callout-danger"> <!-- begin collapsible #deleted-code section -->
<p>
Version 2 and earlier of the unit provided the <em>TPJSysInfo</em> component and various <var>SIGetxxx</var> 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.
</p>
<p class="alert alert-danger glyph">
If you are still using the deprecated code you need to update your code to use the new classes.
</p>
</div> <!-- /#deleted-code -->
<h3 data-toggle="collapse" data-target="#demo" class="collapsible collapsed">
Demo code
</h3>
<div id="demo" class="collapse"> <!-- begin collapsible #demo section -->
<p>
Two demo projects are included in the download in the <code>Demos\VCL</code> and the <code>Demos\FMX</code> 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.
</p>
<p>
Each project contains a tab set where each tab displays the information from one of the classes or the global variables.
</p>
<p>
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.
</p>
</div> <!-- /#demo -->
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Get The Code
</h2>
</div>
<div class="panel-body">
<p>
You can download the latest version of the <em>{{page.title}}</em> directly from SourceForge as <code>{{ dl-file }}</code>.
</p>
<p class="text-center">
<a class="btn btn-primary" role="button" href="{{ dl-url }}" aria-label="Go to SourceForge and download latest version automatically">Download <span class="hidden-xs">release </span>v{{ page.version }}<span class="hidden-xs"> from SourceForge</span></a>
</p>
<p>
The <em>{{ page.title }}</em> source code is hosted in the <a href="{{ page.repo-url }}" aria-label="Link to the ddablib/sysinfo repository on GitHub"><code>ddablib/sysinfo</code></a> GitHub repository. You can <code>git clone</code> or fork the repository as required.
</p>
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Installation
</h2>
</div>
<div class="panel-body">
<p>
The <em>{{ page.title }}</em> is supplied in a zip file. Before installing you need to extract all the files from the zip file, preserving the directory structure. The following files will be extracted:
</p>
<ul class="list-group">
<li class="list-group-item">
<strong><code>PJSysInfo.pas</code></strong> – the source code.
</li>
<li class="list-group-item">
<code>README.md</code> – read-me file.
</li>
<li class="list-group-item">
<code>CHANGELOG.md</code> – project change log.
</li>
<li class="list-group-item">
<code>MPL-2.txt</code> – the Mozilla Public License v2.0.
</li>
<li class="list-group-item">
<code>Documentation.URL</code> – short-cut to the unit's online documentation.
</li>
</ul>
<p>
In addition to the above files you will find the source code of two demo projects and their read-me file in the <code>Demos</code> directory.
</p>
<p>
There are three possible ways to use the unit.
</p>
<ol class="wide">
<li>
The simplest way is to add <code>PJSysInfo.pas</code> to your projects as you need it.
</li>
<li>
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.
</li>
<li>
For maximum portability you can add the unit to a Delphi package. If you need help doing this <a href="{{ site.data.core.install-to-ide-link }}" aria-title="see a tip on working with design time packages">see here</a>.
</li>
</ul>
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Documentation
</h2>
</div>
<div class="panel-body">
<p>
The <em>{{ page.title }}</em> is comprehensively documented online
<a href="{{ page.docs-url }}" aria-title="View the online documentation">here</a>
</p>
<p>
Read-me file: <code><a href="https://github.com/ddablib/sysinfo/blob/main/README.md" aria-title="View the read me file in Markdown format">README.md</a></code>
</p>
<p>
Change log: <code><a href="https://github.com/ddablib/sysinfo/blob/main/CHANGELOG.md" aria-title="View the change log in Markdown format">CHANGELOG.md</a></code>.
</p>
<p>
Acknowledgements: <code><a href="https://github.com/ddablib/sysinfo/blob/main/Docs/Acknowledgements.md" aria-title="View the acknowledgements document in Markdown format">Acknowledgements.md</a></code>.
</p>
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title" id="feedback">
Feedback & Queries
</h2>
</div>
<div class="panel-body">
<p>
If you find any bugs or want to suggest a new feature please report them using the <em>{{page.title}}</em> <a href="https://github.com/ddablib/sysinfo/issues">issue tracker</a>.
</p>
<p>
If you have created a bug fix or have implemented a new feature please open a pull request for it.
</p>
<p>
Should you have any queries about using the classes please read the <a href="{{ page.docs-url }}">documentation</a>. If you can't find an answer in the documentation then post a message in the <a href="https://github.com/orgs/ddablib/discussions">discussion group</a>.
</p>
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
License & Credits
</h2>
</div>
<div class="panel-body">
<p>
<span class="fa fa-copyright fa-pull-left fa-3x"></span> The <em>{{ page.title }}</em> is open source. It is copyright © 2001-2025 by <a href="https://en.gravatar.com/delphidabbler" aria-label="Peter Johnson's Gravatar account">Peter Johnson</a>. The source code is made available under the terms of the <a href="https://www.mozilla.org/MPL/2.0/" aria-label="Mozilla Public License v2.0 on mozilla.org">Mozilla Public License v2.0</a>. All relevant trademarks are acknowledged.
</p>
<p>
Information from numerous websites has been used while developing this code. Several individuals have also suggested solutions or contributed code. Details are provided in the file <a href="https://github.com/ddablib/sysinfo/blob/main/Docs/Acknowledgements.md"><code>Acknowledgements.md</code></a> in the <code>.\Docs</code> subdirectory of the {{ page.title }}'s GitHub repository.
</p>
</div>
</section>