-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathPJSysInfo.pas
5096 lines (4689 loc) · 192 KB
/
PJSysInfo.pas
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/
*
* Copyright (C) 2001-2025, Peter Johnson (https://gravatar.com/delphidabbler).
*
* Except TPJOSInfo.DecodedDigitalProductIDWin8AndUp which is copyright (c) 2020
* Pavel Hruska, MIT license (See https://tinyurl.com/35jybnem).
*
* This unit contains various static classes, constants, type definitions and
* global variables for use in providing information about the host computer and
* operating system.
*
* NOTES
*
* 1: When compiled with old versions of Delphi that do not support setting
* registry access flags via the TRegistry object, some of this code may not
* work correctly when running on 64 bit Windows.
*
* 2: The code has been tested with the Delphi 64 bit compiler (introduced
* in Delphi XE2) and functions correctly.
*
* 3: When run on operating systems up to and including Windows 8 running the
* host program in compatibility mode causes some variables and TPJOSInfo
* methods to be "spoofed" into returning information about the emulated
* OS. When run on Windows 8.1 details of the actual host operating system
* are always returned and the emulated OS is ignored.
*
* 4: On Windows 10 and later the correct operating system will only be
* reported if the application declares the operating systems it supports
* in its manifest.
*
* ACKNOWLEDGEMENTS
*
* See Docs/Acknowledgements.md
}
unit PJSysInfo;
// Define DEBUG whenever debugging.
// *** IMPORTANT: Ensure that DEBUG is NOT defined in production code.
{.$DEFINE DEBUG}
// Define DEBUG_NEW_API if debugging on Windows Vista to Windows 8 in order to
// check that the new version API used for Windows 8.1 and later is working.
// This will cause the new API to be used for Windows Vista and later instead
// of only Windows 8.1 and later.
// *** IMPORTANT: Ensure that DEBUG_NEW_API is NOT defined in production code.
{.$DEFINE DEBUG_NEW_API}
// Conditional defines
// ===================
// Assume all required facilities available
{$DEFINE REGACCESSFLAGS} // TRegistry access flags available
{$DEFINE WARNDIRS} // $WARN compiler directives available
{$DEFINE EXCLUDETRAILING} // SysUtils.ExcludeTrailingPathDelimiter available
{$UNDEF RTLNAMESPACES} // No support for RTL namespaces in unit names
{$UNDEF HASUNIT64} // UInt64 type not defined
{$UNDEF INLINEMETHODS} // No support for inline methods
{$UNDEF HASTBYTES} // TBytes not defined
{$UNDEF STRLENDEPRECATED} // StrLen in SysUtils moved to AnsiStrings
// Undefine facilities not available in earlier compilers
// Note: Delphi 1 to 3 is not included since the code will not compile on these
// compilers
{$IFDEF VER120} // Delphi 4
{$UNDEF REGACCESSFLAGS}
{$UNDEF WARNDIRS}
{$UNDEF EXCLUDETRAILING}
{$ENDIF}
{$IFDEF VER130} // Delphi 5
{$UNDEF REGACCESSFLAGS}
{$UNDEF WARNDIRS}
{$UNDEF EXCLUDETRAILING} // ** fix by Rich Habedank
{$ENDIF}
{$IFDEF VER140} // Delphi 6
{$UNDEF WARNDIRS}
{$ENDIF}
{$IFDEF CONDITIONALEXPRESSIONS}
{$IF CompilerVersion >= 24.0} // Delphi XE3 and later
{$LEGACYIFEND ON} // NOTE: this must come before all $IFEND directives
{$IFEND}
{$IF CompilerVersion >= 25.0}
{$DEFINE STRLENDEPRECATED} // Delphi XE4 and later
{$IFEND}
{$IF CompilerVersion >= 18.5} // Delphi 2007 Win32 and later
{$DEFINE HASTBYTES}
{$IFEND}
{$IF CompilerVersion >= 23.0} // Delphi XE2 and later
{$DEFINE RTLNAMESPACES}
{$IFEND}
{$IF CompilerVersion >= 17.0} // Delphi 2005 and later
{$DEFINE INLINEMETHODS}
{$IFEND}
{$IF Declared(UInt64)}
{$DEFINE HASUINT64}
{$IFEND}
{$ENDIF}
{$WRITEABLECONST OFF}
// Switch off "unsafe" warnings for this unit
{$IFDEF WARNDIRS}
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CODE OFF}
{$ENDIF}
// Switch on range checking when debugging. In production code it's the user's
// choice whether to use range checking or not
{$IFDEF DEBUG}
{$RANGECHECKS ON}
{$ENDIF}
interface
uses
// Delphi
{$IFNDEF RTLNAMESPACES}
SysUtils, Classes, Windows;
{$ELSE}
System.SysUtils,
{$IFDEF STRLENDEPRECATED}
System.AnsiStrings,
{$ENDIF}
System.Classes,
Winapi.Windows;
{$ENDIF}
{$IFNDEF HASTBYTES}
// Compiler doesn't have TBytes: define it
type
TBytes = array of Byte;
{$ENDIF}
type
// Windows types not defined in all supported Delphi VCLs
// ANSI versions of the Win API OSVERSIONINFOEX structure and pointers
_OSVERSIONINFOEXA = packed record
dwOSVersionInfoSize: DWORD; // size of structure
dwMajorVersion: DWORD; // major OS version number
dwMinorVersion: DWORD; // minor OS version number
dwBuildNumber: DWORD; // OS build number
dwPlatformId: DWORD; // OS platform identifier
szCSDVersion: array[0..127] of AnsiChar; // service pack or extra info
wServicePackMajor: WORD; // service pack major version no.
wServicePackMinor: WORD; // service pack minor version no.
wSuiteMask: WORD; // bitmask that stores OS suite(s)
wProductType: Byte; // additional info about system
wReserved: Byte; // reserved for future use
end;
OSVERSIONINFOEXA = _OSVERSIONINFOEXA;
TOSVersionInfoExA = _OSVERSIONINFOEXA;
POSVersionInfoExA = ^TOSVersionInfoExA;
// Unicode versions of the Win API OSVERSIONINFOEX structure and pointers
_OSVERSIONINFOEXW = packed record
dwOSVersionInfoSize: DWORD; // size of structure
dwMajorVersion: DWORD; // major OS version number
dwMinorVersion: DWORD; // minor OS version number
dwBuildNumber: DWORD; // OS build number
dwPlatformId: DWORD; // OS platform identifier
szCSDVersion: array[0..127] of WideChar; // service pack or extra info
wServicePackMajor: WORD; // service pack major version no.
wServicePackMinor: WORD; // service pack minor version no.
wSuiteMask: WORD; // bitmask that stores OS suite(s)
wProductType: Byte; // additional info about system
wReserved: Byte; // reserved for future use
end;
OSVERSIONINFOEXW = _OSVERSIONINFOEXW;
TOSVersionInfoExW = _OSVERSIONINFOEXW;
POSVersionInfoExW = ^TOSVersionInfoExW;
// Default version of the Win API OSVERSIONINFOEX structure.
// UNICODE is defined when the Unicode API is used, so we use this to decide
// which structure to use as default.
{$IFDEF UNICODE}
_OSVERSIONINFOEX = _OSVERSIONINFOEXW;
OSVERSIONINFOEX = OSVERSIONINFOEXW;
TOSVersionInfoEx = TOSVersionInfoExW;
POSVersionInfoEx = POSVersionInfoExW;
{$ELSE}
_OSVERSIONINFOEX = _OSVERSIONINFOEXA;
OSVERSIONINFOEX = OSVERSIONINFOEXA;
TOSVersionInfoEx = TOSVersionInfoExA;
POSVersionInfoEx = POSVersionInfoExA;
{$ENDIF}
const
// Windows constants possibly not defined in all supported Delphi VCLs
// Conditional consts used in VerSetConditionMask calls
VER_EQUAL = 1; // current value = specified value.
VER_GREATER = 2; // current value > specified value.
VER_GREATER_EQUAL = 3; // current value >= specified value.
VER_LESS = 4; // current value < specified value.
VER_LESS_EQUAL = 5; // current value <= specified value.
// Platform ID defines
// these are not included in Windows unit of all supported Delphis
VER_BUILDNUMBER = $00000004;
VER_MAJORVERSION = $00000002;
VER_MINORVERSION = $00000001;
VER_PLATFORMID = $00000008;
VER_SERVICEPACKMAJOR = $00000020;
VER_SERVICEPACKMINOR = $00000010;
VER_SUITENAME = $00000040;
VER_PRODUCT_TYPE = $00000080;
// Constants from sdkddkver.h
_WIN32_WINNT_NT4 = $0400; // Windows NT 4
_WIN32_WINNT_WIN2K = $0500; // Windows 2000
_WIN32_WINNT_WINXP = $0501; // Windows XP
_WIN32_WINNT_WS03 = $0502; // Windows Server 2003
_WIN32_WINNT_WIN6 = $0600; // Windows Vista
_WIN32_WINNT_VISTA = $0600; // Windows Vista
_WIN32_WINNT_WS08 = $0600; // Windows Server 2008
_WIN32_WINNT_LONGHORN = $0600; // Windows Vista
_WIN32_WINNT_WIN7 = $0601; // Windows 7
_WIN32_WINNT_WIN8 = $0602; // Windows 8
_WIN32_WINNT_WINBLUE = $0603; // Windows 8.1
_WIN32_WINNT_WINTHRESHOLD = $0A00; // Windows 10
_WIN32_WINNT_WIN10 = $0A00; // Windows 10
// These Windows-defined constants are required for use with TOSVersionInfoEx
// NT Product types
VER_NT_WORKSTATION = 1;
VER_NT_DOMAIN_CONTROLLER = 2;
VER_NT_SERVER = 3;
// Mask representing NT product suites
VER_SUITE_SMALLBUSINESS = $00000001;
VER_SUITE_ENTERPRISE = $00000002;
VER_SUITE_BACKOFFICE = $00000004;
VER_SUITE_COMMUNICATIONS = $00000008;
VER_SUITE_TERMINAL = $00000010;
VER_SUITE_SMALLBUSINESS_RESTRICTED = $00000020;
VER_SUITE_EMBEDDEDNT = $00000040;
VER_SUITE_DATACENTER = $00000080;
VER_SUITE_SINGLEUSERTS = $00000100;
VER_SUITE_PERSONAL = $00000200;
VER_SUITE_SERVERAPPLIANCE = $00000400;
VER_SUITE_BLADE = VER_SUITE_SERVERAPPLIANCE;
VER_SUITE_EMBEDDED_RESTRICTED = $00000800;
VER_SUITE_SECURITY_APPLIANCE = $00001000;
VER_SUITE_STORAGE_SERVER = $00002000;
VER_SUITE_COMPUTE_SERVER = $00004000;
VER_SUITE_WH_SERVER = $00008000;
// These Windows-defined constants are required for use with the
// GetProductInfo API call used with Windows Vista and later
// NOTE: PRODUCT_xxx constants marked with an asterisk comment have no
// associated description hard wired into this unit.
// ** Thanks to Laurent Pierre for providing these definitions originally.
// ** Subsequent additions were obtained from https://tinyurl.com/3rhhbs2z
// ** and the Windows 11 24H2 SDK
PRODUCT_UNDEFINED = $00000000;
PRODUCT_ULTIMATE = $00000001;
PRODUCT_HOME_BASIC = $00000002;
PRODUCT_HOME_PREMIUM = $00000003;
PRODUCT_ENTERPRISE = $00000004;
PRODUCT_HOME_BASIC_N = $00000005;
PRODUCT_BUSINESS = $00000006;
PRODUCT_STANDARD_SERVER = $00000007;
PRODUCT_DATACENTER_SERVER = $00000008;
PRODUCT_SMALLBUSINESS_SERVER = $00000009;
PRODUCT_ENTERPRISE_SERVER = $0000000A;
PRODUCT_STARTER = $0000000B;
PRODUCT_DATACENTER_SERVER_CORE = $0000000C;
PRODUCT_STANDARD_SERVER_CORE = $0000000D;
PRODUCT_ENTERPRISE_SERVER_CORE = $0000000E;
PRODUCT_ENTERPRISE_SERVER_IA64 = $0000000F;
PRODUCT_BUSINESS_N = $00000010;
PRODUCT_WEB_SERVER = $00000011;
PRODUCT_CLUSTER_SERVER = $00000012;
PRODUCT_HOME_SERVER = $00000013;
PRODUCT_STORAGE_EXPRESS_SERVER = $00000014;
PRODUCT_STORAGE_STANDARD_SERVER = $00000015;
PRODUCT_STORAGE_WORKGROUP_SERVER = $00000016;
PRODUCT_STORAGE_ENTERPRISE_SERVER = $00000017;
PRODUCT_SERVER_FOR_SMALLBUSINESS = $00000018;
PRODUCT_SMALLBUSINESS_SERVER_PREMIUM = $00000019;
PRODUCT_HOME_PREMIUM_N = $0000001A;
PRODUCT_ENTERPRISE_N = $0000001B;
PRODUCT_ULTIMATE_N = $0000001C;
PRODUCT_WEB_SERVER_CORE = $0000001D;
PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT = $0000001E;
PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY = $0000001F;
PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING = $00000020;
PRODUCT_SERVER_FOUNDATION = $00000021;
PRODUCT_HOME_PREMIUM_SERVER = $00000022;
PRODUCT_SERVER_FOR_SMALLBUSINESS_V = $00000023;
PRODUCT_STANDARD_SERVER_V = $00000024;
PRODUCT_DATACENTER_SERVER_V = $00000025;
PRODUCT_ENTERPRISE_SERVER_V = $00000026;
PRODUCT_DATACENTER_SERVER_CORE_V = $00000027;
PRODUCT_STANDARD_SERVER_CORE_V = $00000028;
PRODUCT_ENTERPRISE_SERVER_CORE_V = $00000029;
PRODUCT_HYPERV = $0000002A;
PRODUCT_STORAGE_EXPRESS_SERVER_CORE = $0000002B;
PRODUCT_STORAGE_STANDARD_SERVER_CORE = $0000002C;
PRODUCT_STORAGE_WORKGROUP_SERVER_CORE = $0000002D;
PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE = $0000002E;
PRODUCT_STARTER_N = $0000002F;
PRODUCT_PROFESSIONAL = $00000030;
PRODUCT_PROFESSIONAL_N = $00000031;
PRODUCT_SB_SOLUTION_SERVER = $00000032;
PRODUCT_SERVER_FOR_SB_SOLUTIONS = $00000033;
PRODUCT_STANDARD_SERVER_SOLUTIONS = $00000034;
PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE = $00000035;
PRODUCT_SB_SOLUTION_SERVER_EM = $00000036;
PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM = $00000037;
PRODUCT_SOLUTION_EMBEDDEDSERVER = $00000038;
PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE = $00000039; // *
PRODUCT_PROFESSIONAL_EMBEDDED = $0000003A; // *
PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT = $0000003B;
PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL = $0000003C;
PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC = $0000003D;
PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC = $0000003E;
PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE = $0000003F;
PRODUCT_CLUSTER_SERVER_V = $00000040;
PRODUCT_EMBEDDED = $00000041; // *
PRODUCT_STARTER_E = $00000042;
PRODUCT_HOME_BASIC_E = $00000043;
PRODUCT_HOME_PREMIUM_E = $00000044;
PRODUCT_PROFESSIONAL_E = $00000045;
PRODUCT_ENTERPRISE_E = $00000046;
PRODUCT_ULTIMATE_E = $00000047;
PRODUCT_ENTERPRISE_EVALUATION = $00000048;
PRODUCT_MULTIPOINT_STANDARD_SERVER = $0000004C;
PRODUCT_MULTIPOINT_PREMIUM_SERVER = $0000004D;
PRODUCT_STANDARD_EVALUATION_SERVER = $0000004F;
PRODUCT_DATACENTER_EVALUATION_SERVER = $00000050;
PRODUCT_ENTERPRISE_N_EVALUATION = $00000054;
PRODUCT_EMBEDDED_AUTOMOTIVE = $00000055; // *
PRODUCT_EMBEDDED_INDUSTRY_A = $00000056; // *
PRODUCT_THINPC = $00000057; // *
PRODUCT_EMBEDDED_A = $00000058; // *
PRODUCT_EMBEDDED_INDUSTRY = $00000059; // *
PRODUCT_EMBEDDED_E = $0000005A; // *
PRODUCT_EMBEDDED_INDUSTRY_E = $0000005B; // *
PRODUCT_EMBEDDED_INDUSTRY_A_E = $0000005C; // *
PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER = $0000005F;
PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER = $00000060;
PRODUCT_CORE_ARM = $00000061;
PRODUCT_CORE_N = $00000062;
PRODUCT_CORE_COUNTRYSPECIFIC = $00000063;
PRODUCT_CORE_SINGLELANGUAGE = $00000064;
PRODUCT_CORE = $00000065;
PRODUCT_PROFESSIONAL_WMC = $00000067;
PRODUCT_MOBILE_CORE = $00000068;
PRODUCT_EMBEDDED_INDUSTRY_EVAL = $00000069; // *
PRODUCT_EMBEDDED_INDUSTRY_E_EVAL = $0000006A; // *
PRODUCT_EMBEDDED_EVAL = $0000006B; // *
PRODUCT_EMBEDDED_E_EVAL = $0000006C; // *
PRODUCT_NANO_SERVER = $0000006D; // *
PRODUCT_CLOUD_STORAGE_SERVER = $0000006E; // *
PRODUCT_CORE_CONNECTED = $0000006F; // *
PRODUCT_PROFESSIONAL_STUDENT = $00000070; // *
PRODUCT_CORE_CONNECTED_N = $00000071; // *
PRODUCT_PROFESSIONAL_STUDENT_N = $00000072; // *
PRODUCT_CORE_CONNECTED_SINGLELANGUAGE = $00000073; // *
PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC = $00000074; // *
PRODUCT_CONNECTED_CAR = $00000075; // *
PRODUCT_INDUSTRY_HANDHELD = $00000076; // *
PRODUCT_PPI_PRO = $00000077; // *
PRODUCT_ARM64_SERVER = $00000078; // *
PRODUCT_EDUCATION = $00000079;
PRODUCT_EDUCATION_N = $0000007A;
PRODUCT_IOTUAP = $0000007B;
PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER = $0000007C; // *
PRODUCT_ENTERPRISE_S = $0000007D;
PRODUCT_ENTERPRISE_S_N = $0000007E;
PRODUCT_PROFESSIONAL_S = $0000007F; // *
PRODUCT_PROFESSIONAL_S_N = $00000080; // *
PRODUCT_ENTERPRISE_S_EVALUATION = $00000081;
PRODUCT_ENTERPRISE_S_N_EVALUATION = $00000082;
PRODUCT_IOTUAPCOMMERCIAL = $00000083;
PRODUCT_MOBILE_ENTERPRISE = $00000085;
PRODUCT_HOLOGRAPHIC = $00000087; // *
PRODUCT_HOLOGRAPHIC_BUSINESS = $00000088; // *
PRODUCT_PRO_SINGLE_LANGUAGE = $0000008A; // *
PRODUCT_PRO_CHINA = $0000008B; // *
PRODUCT_ENTERPRISE_SUBSCRIPTION = $0000008C; // *
PRODUCT_ENTERPRISE_SUBSCRIPTION_N = $0000008D; // *
PRODUCT_DATACENTER_NANO_SERVER = $0000008F;
PRODUCT_STANDARD_NANO_SERVER = $00000090;
PRODUCT_DATACENTER_A_SERVER_CORE = $00000091;
PRODUCT_STANDARD_A_SERVER_CORE = $00000092;
PRODUCT_DATACENTER_WS_SERVER_CORE = $00000093;
PRODUCT_STANDARD_WS_SERVER_CORE = $00000094;
PRODUCT_UTILITY_VM = $00000095; // *
PRODUCT_DATACENTER_EVALUATION_SERVER_CORE = $0000009F; // *
PRODUCT_STANDARD_EVALUATION_SERVER_CORE = $000000A0; // *
PRODUCT_PRO_WORKSTATION = $000000A1;
PRODUCT_PRO_WORKSTATION_N = $000000A2;
PRODUCT_PRO_FOR_EDUCATION = $000000A4;
PRODUCT_PRO_FOR_EDUCATION_N = $000000A5; // *
PRODUCT_AZURE_SERVER_CORE = $000000A8; // *
PRODUCT_AZURE_NANO_SERVER = $000000A9; // *
PRODUCT_ENTERPRISEG = $000000AB; // *
PRODUCT_ENTERPRISEGN = $000000AC; // *
PRODUCT_SERVERRDSH = $000000AF;
PRODUCT_CLOUD = $000000B2; // *
PRODUCT_CLOUDN = $000000B3; // *
PRODUCT_HUBOS = $000000B4; // *
PRODUCT_ONECOREUPDATEOS = $000000B6; // *
PRODUCT_CLOUDE = $000000B7; // *
PRODUCT_IOTOS = $000000B9; // *
PRODUCT_CLOUDEN = $000000BA; // *
PRODUCT_IOTEDGEOS = $000000BB; // *
PRODUCT_IOTENTERPRISE = $000000BC;
PRODUCT_LITE = $000000BD; // *
PRODUCT_IOTENTERPRISE_S = $000000BF;
PRODUCT_XBOX_SYSTEMOS = $000000C0; // *
PRODUCT_XBOX_GAMEOS = $000000C2; // *
PRODUCT_XBOX_ERAOS = $000000C3; // *
PRODUCT_XBOX_DURANGOHOSTOS = $000000C4; // *
PRODUCT_XBOX_SCARLETTHOSTOS = $000000C5; // *
PRODUCT_XBOX_KEYSTONE = $000000C6; // *
PRODUCT_AZURE_SERVER_CLOUDHOST = $000000C7; // *
PRODUCT_AZURE_SERVER_CLOUDMOS = $000000C8; // *
PRODUCT_CLOUDEDITIONN = $000000CA; // *
PRODUCT_CLOUDEDITION = $000000CB; // *
PRODUCT_VALIDATION = $000000CC; // *
PRODUCT_IOTENTERPRISESK = $000000CD; // *
PRODUCT_IOTENTERPRISEK = $000000CE; // *
PRODUCT_IOTENTERPRISESEVAL = $000000CF; // *
PRODUCT_AZURE_SERVER_AGENTBRIDGE = $000000D0; // *
PRODUCT_AZURE_SERVER_NANOHOST = $000000D1; // *
PRODUCT_WNC = $000000D2; // *
PRODUCT_AZURESTACKHCI_SERVER_CORE = $00000196; // *
PRODUCT_DATACENTER_SERVER_AZURE_EDITION = $00000197;
PRODUCT_DATACENTER_SERVER_CORE_AZURE_EDITION = $00000198; // *
PRODUCT_UNLICENSED = $ABCDABCD;
// These constants are required for use with GetSystemMetrics to detect
// certain editions. GetSystemMetrics returns non-zero when passed these flags
// if the associated edition is present.
// Obtained from https://msdn.microsoft.com/en-us/library/ms724385
SM_TABLETPC = 86; // Detects XP Tablet Edition
SM_MEDIACENTER = 87; // Detects XP Media Center Edition
SM_STARTER = 88; // Detects XP Starter Edition
SM_SERVERR2 = 89; // Detects Windows Server 2003 R2
SM_REMOTESESSION = $1000; // Detects a remote terminal server session
// These constants are required when examining the
// TSystemInfo.wProcessorArchitecture member.
// Only constants marked ** are defined in MS docs at 2022-12-31
PROCESSOR_ARCHITECTURE_UNKNOWN = $FFFF; // Unknown architecture *
PROCESSOR_ARCHITECTURE_INTEL = 0; // x86 *
PROCESSOR_ARCHITECTURE_MIPS = 1; // MIPS architecture
PROCESSOR_ARCHITECTURE_ALPHA = 2; // Alpha architecture
PROCESSOR_ARCHITECTURE_PPC = 3; // PPC architecture
PROCESSOR_ARCHITECTURE_SHX = 4; // SHX architecture
PROCESSOR_ARCHITECTURE_ARM = 5; // ARM architecture *
PROCESSOR_ARCHITECTURE_IA64 = 6; // Intel Itanium based *
PROCESSOR_ARCHITECTURE_ALPHA64 = 7; // Alpha64 architecture
PROCESSOR_ARCHITECTURE_MSIL = 8; // MSIL architecture
PROCESSOR_ARCHITECTURE_AMD64 = 9; // x64 (AMD or Intel) *
PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 = 10; // IA32 on Win64 architecture
PROCESSOR_ARCHITECTURE_ARM64 = 12; // ARM64 architecture *
// These constants are provided in case the obsolete
// TSystemInfo.dwProcessorType needs to be used.
// Constants marked Windows CE are only used on Windows mobile and are only
// provided here for completeness.
// Only constants marked * are defined in MS SDK 6.1
PROCESSOR_INTEL_386 = 386; // Intel i386 processor *
PROCESSOR_INTEL_486 = 486; // Intel i486 processor *
PROCESSOR_INTEL_PENTIUM = 586; // Intel Pentium processor *
PROCESSOR_INTEL_IA64 = 2200; // Intel IA64 processor *
PROCESSOR_AMD_X8664 = 8664; // AMD X86 64 processor *
PROCESSOR_MIPS_R4000 = 4000; // MIPS R4000, R4101, R3910 processor
PROCESSOR_ALPHA_21064 = 21064; // Alpha 210 64 processor
PROCESSOR_PPC_601 = 601; // PPC 601 processor
PROCESSOR_PPC_603 = 603; // PPC 603 processor
PROCESSOR_PPC_604 = 604; // PPC 604 processor
PROCESSOR_PPC_620 = 620; // PPC 620 processor
PROCESSOR_HITACHI_SH3 = 10003; // Hitachi SH3 processor (Windows CE)
PROCESSOR_HITACHI_SH3E = 10004; // Hitachi SH3E processor (Windows CE)
PROCESSOR_HITACHI_SH4 = 10005; // Hitachi SH4 processor (Windows CE)
PROCESSOR_MOTOROLA_821 = 821; // Motorola 821 processor (Windows CE)
PROCESSOR_SHx_SH3 = 103; // SHx SH3 processor (Windows CE)
PROCESSOR_SHx_SH4 = 104; // SHx SH4 processor (Windows CE)
PROCESSOR_STRONGARM = 2577; // StrongARM processor (Windows CE)
PROCESSOR_ARM720 = 1824; // ARM 720 processor (Windows CE)
PROCESSOR_ARM820 = 2080; // ARM 820 processor (Windows CE)
PROCESSOR_ARM920 = 2336; // ARM 920 processor (Windows CE)
PROCESSOR_ARM_7TDMI = 70001; // ARM 7TDMI processor (Windows CE)
PROCESSOR_OPTIL = $494F; // MSIL processor
type
/// <summary>Enumeration of OS platforms.</summary>
TPJOSPlatform = (
ospWinNT, // Windows NT platform
ospWin9x, // Windows 9x platform
ospWin32s // Win32s platform
);
type
/// <summary>Enumeration identifying OS product.</summary>
/// <remarks>New values are always appended to the end of the enumeration so
/// as not to destroy any existing code that depends on the ordinal value of
/// the existing values.</remarks>
TPJOSProduct = (
osUnknownWinNT, // Unknown Windows NT OS
osWinNT, // Windows NT (up to v4)
osWin2K, // Windows 2000
osWinXP, // Windows XP
osUnknownWin9x, // Unknown Windows 9x OS
osWin95, // Windows 95
osWin98, // Windows 98
osWinMe, // Windows Me
osUnknownWin32s, // Unknown OS running Win32s
osWinSvr2003, // Windows Server 2003
osUnknown, // Completely unknown Windows
osWinVista, // Windows Vista
osWinSvr2003R2, // Windows Server 2003 R2
osWinSvr2008, // Windows Server 2008
osWinLater, // A later version of Windows than v6.1
osWin7, // Windows 7
osWinSvr2008R2, // Windows Server 2008 R2
osWin8, // Windows 8
osWinSvr2012, // Windows Server 2012
osWin8Point1, // Windows 8.1
osWinSvr2012R2, // Windows Server 2012 R2
osWin10, // Windows 10
osWin10Svr, // Windows 2016 Server
osWinSvr2019, // Windows 2019 Server
osWin11, // Windows 11
osWinSvr2022, // Windows 2022 Server
osWinServer, // Windows Server (between Server 2019 & 2022)
osWinSvr2025, // Windows 2025 Server
osWinSvrLater // Later Windows Server
);
type
/// <summary>Enumeration identifying processor architecture.</summary>
TPJProcessorArchitecture = (
paUnknown, // Unknown architecture
paX64, // X64 (AMD or Intel)
paIA64, // Intel Itanium processor family (IPF)
paX86 // Intel 32 bit
);
type
/// <summary>Enumeration identifying system boot modes.</summary>
TPJBootMode = (
bmUnknown, // Unknown boot mode
bmNormal, // Normal boot
bmSafeMode, // Booted in safe mode
bmSafeModeNetwork // Booted in safe node with networking
);
type
/// <summary>Enumeration identifying the possible reasons for a computer to
/// be powered on.</summary>
/// <remarks>For details of the values see the SMBIOS reference specification
/// v3.7.0 at https://tinyurl.com/4mhpy4xz, section 7.2.2.</remarks>
TPJBiosWakeupType = (
wutReserved, // 0
wutOther, // 1
wutUnknown, // 2
wutAPMTimer, // 3
wutModemRing, // 4
wutLANRemote, // 5
wutPowerSwitch, // 6
wutPCIPME, // 7
wutACPowerRestored // 8
);
type
// Various Windows 10 & 11 release versions
TPJWin10PlusVersion = (
win10plusNA,
win10plusUnknown,
win10v1507, win10v1511, win10v1607, win10v1703, win10v1709, win10v1803,
win10v1809, win10v1903, win10v1909, win10v2004, win10v20H2, win10v21H1,
win10v21H2, win10v22H2,
win11v21H2, win11v22H2, win11v23H2, win11v24H2
);
type
/// <summary>Class of exception raised by code in this unit.</summary>
EPJSysInfo = class(Exception);
type
/// <summary>Static class that provides operating system version information.
/// </summary>
TPJOSInfo = class(TObject)
private
/// <summary>Gets description of OS product edition from value returned
/// from GetProductInfo API.</summary>
class function EditionFromProductInfo: string;
/// <summary>Checks if a given suite is installed on an NT system.
/// </summary>
/// <param name="Suite">Integer [in] One of the VER_SUITE_* flags.</param>
/// <returns>True if suite is installed, False if not installed or not an
/// NT platform OS.</returns>
class function CheckSuite(const Suite: Integer): Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Gets product edition from registry for NT4 pre SP6.</remarks>
class function NTEditionFromReg: string;
/// <summary>Gets edition ID from registry.</summary>
class function EditionIDFromReg: string;
/// <summary>Checks registry to see if NT4 Service Pack 6a is installed.
/// </summary>
class function IsNT4SP6a: Boolean;
/// <summary>Gets code describing product type from registry.</summary>
/// <remarks>Used to get product type for NT4 SP5 and earlier.</remarks>
class function ProductTypeFromReg: string;
/// <summary>Checks if the underlying operating system either has the given
/// major and minor version number and service pack major version numbers
/// or is a later version.</summary>
/// <remarks>
/// <para>MajorVersion version must be greater than or equal to 5,
/// otherwise the method always returns False.</para>
/// <para>This method is immune to spoofing: it always returns information
/// about the actual operating system.</para>
/// </remarks>
class function IsReallyWindowsVersionOrGreater(MajorVersion, MinorVersion,
ServicePackMajor: Word): Boolean;
/// <summary>Checks if the operating system is Windows 10 or later, with a
/// version identifier the same or later than the given version identifier.
/// </summary>
/// <remarks>
/// <para>WARNING: Windows 11 versions are always considered to be later
/// Windows 10 versions, even if the Windows 10 version was released after
/// the Windows 11 version.</para>
/// <para><c>AVersion</c> must not be one of <c>win10plusNA</c> or
/// <c>win10plusUnknown</c>.</para>
class function IsWindows10PlusVersionOrLater(
const AVersion: TPJWin10PlusVersion): Boolean;
/// <summary>Returns the string containing the decoded digital product ID
/// of the host OS on Windows 8 and later only, or an empty string if
/// the digital product ID is not valid.</summary>
/// <remarks>The caller must check the OS version before calling this
/// method.</remarks>
class function DecodedDigitalProductIDWin8AndUp: string;
/// <summary>Returns the string containing the decoded digital product ID
/// of the host OS on Windows 7 and earlier only, or an empty string if
/// the digital product ID is not valid.</summary>
/// <remarks>The caller must check the OS version before calling this
/// method.</remarks>
class function DecodedDigitalProductIDWin7AndDown: string;
public
/// <summary>Checks if the OS can be "spoofed" by specifying a
/// compatibility mode for the program.</summary>
/// <remarks>When this method returns True public methods of TPJOSInfo
/// will return the details of OS emulated by the compatibility mode OS
/// instead of the actual OS, unless the method is documented to the
/// contrary. When False is returned the reported OS is the real underlying
/// OS and any compatibility mode is ignored.</remarks>
class function CanSpoof: Boolean;
/// <summary>Checks if the OS is on the Windows 9x platform.</summary>
class function IsWin9x: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks if the OS is on the Windows NT platform.</summary>
class function IsWinNT: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks if the program is hosted on Win32s.</summary>
/// <remarks>This is unlikely to ever return True since Delphi does not run
/// on Win32s.</remarks>
class function IsWin32s: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks if a 32 bit program is running under WOW64 on a 64 bit
/// operating system.</summary>
class function IsWow64: Boolean;
/// <summary>Checks if the program is running on a server operating system.
/// </summary>
/// <remarks>Use IsWindowsServer in preference.</remarks>
class function IsServer: Boolean;
/// <summary>Checks if Windows Media Center is installed.</summary>
class function IsMediaCenter: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks if the program is running on a tablet PC OS.</summary>
class function IsTabletPC: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks if the program is running under Windows Terminal Server
/// as a client session.</summary>
class function IsRemoteSession: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks of the host operating system has pen extensions
/// installed.</summary>
class function HasPenExtensions: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Returns the host OS platform identifier.</summary>
class function Platform: TPJOSPlatform;
/// <summary>Returns the host OS product identifier.</summary>
class function Product: TPJOSProduct;
/// <summary>Returns the product name of the host OS.</summary>
class function ProductName: string;
/// <summary>Returns the major version number of the host OS.</summary>
class function MajorVersion: Integer;
/// <summary>Returns the minor version number of the host OS.</summary>
class function MinorVersion: Integer;
/// <summary>Returns the host OS's build number.</summary>
/// <remarks>A return value of 0 indicates that the build number can't be
/// found.</remarks>
class function BuildNumber: Integer;
/// <summary>Returns the name of any installed OS service pack.</summary>
class function ServicePack: string;
/// <summary>Returns the name of any installed OS service pack along with
/// other similar, detectable, updates.</summary>
/// <remarks>
/// <para>Windows has added significant OS updates that bump the build
/// number but do not declare themselves as service packs: e.g. the Windows
/// 10 TH2 update, aka Version 1511.</para>
/// <para>This method is used to report such updates in addition to
/// updates that declare themselves as service packs, while the ServicePack
/// method only reports declared 'official' service packs.</para>
/// </remarks>
class function ServicePackEx: string;
/// <summary>Returns the major version number of any NT platform service
/// pack.</summary>
/// <remarks>0 is returned in no service pack is installed, if the host OS
/// is not on the NT platform.</remarks>
class function ServicePackMajor: Integer;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Returns the minor version number of any NT platform service
/// pack.</summary>
/// <remarks>Invalid if ServicePackMajor returns 0.</remarks>
class function ServicePackMinor: Integer;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Returns the product edition for an NT platform OS.</summary>
/// <remarks>The empty string is returned if the OS is not on the NT
/// platform.</remarks>
class function Edition: string;
/// <summary>Returns a full description of the host OS.</summary>
class function Description: string;
/// <summary>Returns the Windows product ID of the host OS.</summary>
class function ProductID: string;
/// <summary>Returns the digital product ID of the host OS.</summary>
class function DigitalProductID: TBytes;
/// <summary>Returns the string containing the decoded digital product ID
/// of the host OS, or an empty string if the digital product ID contains
/// insufficient data.</summary>
class function DecodedDigitalProductID: string;
/// <summary>Organisation to which Windows is registered, if any.</summary>
class function RegisteredOrganisation: string;
/// <summary>Owner to which Windows is registered.</summary>
class function RegisteredOwner: string;
/// <summary>Date the operating system was installed.</summary>
/// <remarks>If this information is not available then <c>0.0</c> is
/// returned (i.e. 1899/12/30).</remarks>
class function InstallationDate: TDateTime;
/// <summary>Checks whether the OS is Windows 2000 or greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force.</remarks>
class function IsReallyWindows2000OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 2000 Service Pack 1 or
/// greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force.</remarks>
class function IsReallyWindows2000SP1OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 2000 Service Pack 2 or
/// greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force.</remarks>
class function IsReallyWindows2000SP2OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 2000 Service Pack 3 or
/// greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force.</remarks>
class function IsReallyWindows2000SP3OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 2000 Service Pack 4 or
/// greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force.</remarks>
class function IsReallyWindows2000SP4OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows XP or greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindowsXPOrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows XP Service Pack 1 or greater.
/// </summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindowsXPSP1OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows XP Service Pack 2 or greater.
/// </summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindowsXPSP2OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows XP Service Pack 3 or greater.
/// </summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindowsXPSP3OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows Vista or greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindowsVistaOrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows Vista Service Pack 1 or
/// greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindowsVistaSP1OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows Vista Service Pack 2 or
/// greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindowsVistaSP2OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 7 or greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindows7OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 7 Service Pack 1 or greater.
/// </summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindows7SP1OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 8 or greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindows8OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 8.1 or greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force or whether a suitable
/// manifest file is present.</remarks>
class function IsReallyWindows8Point1OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Checks whether the OS is Windows 10 or greater.</summary>
/// <remarks>This method always returns information about the true OS,
/// regardless of any compatibility mode in force, but DOES require that
/// the correct manifest file is present.</remarks>
class function IsReallyWindows10OrGreater: Boolean;
{$IFDEF INLINEMETHODS}inline;{$ENDIF}
/// <summary>Returns an identifier representing a Windows 10 or 11
/// version.</summary>
/// <remarks>If the OS is earlier than Windows 10 then <c>win10plusNA</c>
/// is returned. If the OS is Windows 10 or later but is a dev, beta etc.
/// build whose version can't be detected then <c>win10plusUnknown</c> is
/// returned.</remarks>
class function Windows10PlusVersion: TPJWin10PlusVersion;
/// <summary>Returns the version name of a the current operating system, if
/// it is Windows 10 or later.</summary>
/// <remarks>
/// <para>NOTE: some Windows 10 and 11 versions have the same string.
/// </para>
/// <para>If the OS is earlier than Windows 10 then an empty string is
/// returned. If the OS is Windows 10 or later but is a dev, beta etc.
/// build whose version can't be detected then 'Unknown' is returned.
/// </para>
/// </remarks>
class function Windows10PlusVersionName: string;
/// <summary>Checks if the operating system is Windows 10 or later, with a
/// version identifier the same or later than <c>AVersion</c>.
/// </summary>
/// <remarks><c>AVersion</c> must be a valid Windows 10 version
/// identifier, with a name that begins with <c>win10v</c>.</remarks>
/// <exception><c>EPJSysInfo</c> raised if <c>AVersion</c> is not a valid
/// Windows 10 version identifier.</exception>
class function IsWindows10VersionOrLater(
const AVersion: TPJWin10PlusVersion): Boolean;
/// <summary>Checks if the operating system is Windows 11 or later, with a
/// version identifier the same or later than <c>AVersion</c>.
/// </summary>
/// <remarks><c>AVersion</c> must be a valid Windows 11 version
/// identifier, with a name that begins with <c>win11v</c>.</remarks>
/// <exception><c>EPJSysInfo</c> raised if <c>AVersion</c> is not a valid
/// Windows 11 version identifier.</exception>
class function IsWindows11VersionOrLater(
const AVersion: TPJWin10PlusVersion): Boolean;
/// <summary>Checks if the OS is a server version.</summary>
/// <remarks>
/// <para>For Windows 2000 and later the result always relates to the
/// actual OS, regardless of any compatibility mode in force. For versions
/// prior to Windows 2000 this method will take note of compatibility modes
/// and returns the same value as TPJOSInfo.IsServer.</para>
/// <para>WARNING: For Windows 10 this method is likely to succeed only if
/// the application is correctly manifested.</para>
class function IsWindowsServer: Boolean;
/// <summary>Returns any revision number for the OS.</summary>
/// <remarks>
/// <para>If the OS does not provide any revision information then zero is
/// returned.</para>
/// <para>This value is read fromt he registry therefore it is possible
/// that this value could be spoofed.</para>
/// </remarks>
class function RevisionNumber: Integer;
/// <summary>Returns the repository branch from which the OS release was]
/// built.</summary>
/// <remarks>Returns the empty string if no build branch information is
/// available.</remarks>
class function BuildBranch: string;
end;
type
/// <summary>Static class that provides information about the host computer.
/// </summary>
TPJComputerInfo = class(TObject)
public
/// <summary>Returns name of host computer.</summary>
class function ComputerName: string;
/// <summary>Returns name of currently logged on user.</summary>
class function UserName: string;
/// <summary>Returns MAC address of 1st Ethernet adapter on host computer.
/// or empty string if no such adapter is found.
/// </summary>
/// <remarks>**WARNING** may be unreliable - see comments in
/// implementation. </remarks>