演示:

program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils, TlHelp32,Classes, PsAPI, Windows,Registry;
(* IsWindows10 function supports official RTM and above only *)
function isWindows10:boolean;
var
Reg: TRegistry;
begin
Result := False;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows NT\CurrentVersion') then
begin
if Reg.ValueExists('CurrentVersion') then
if (Reg.ReadString('CurrentVersion') = '6.3')
and (StrToInt (Reg.ReadString('CurrentBuildNumber')) >= 10240) then
Result := True;
end;
finally
Reg.Free;
end;
end;
function RtlGetVersion(var RTL_OSVERSIONINFOEXW): LONG; stdcall; external 'ntdll.dll' Name 'RtlGetVersion';
function isWindows11:Boolean;
var
winver: RTL_OSVERSIONINFOEXW;
begin
Result := False;
if ((RtlGetVersion(winver) = 0) and (winver.dwMajorVersion>=10) and (winver.dwBuildNumber > 22000)) then
Result := True;
end;
var
h:HWND;
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
Writeln('isWindows10:');
Writeln(isWindows10);
Writeln('isWindows11:');
Writeln(isWindows11);
readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.20347094535828 seconds