gpt4 book ai didi

delphi - 如何确定操作系统

转载 作者:行者123 更新时间:2023-12-03 14:39:15 25 4
gpt4 key购买 nike

如何实现返回操作系统名称的函数?检测程序运行的环境?

win2000/xp/vista/win7 等...?

最佳答案

类似这样的事情:

function osver: string;
begin
result := 'Unknown (Windows ' + IntToStr(Win32MajorVersion) + '.' + IntToStr(Win32MinorVersion) + ')';
case Win32MajorVersion of
4:
case Win32MinorVersion of
0: result := 'Windows 95';
10: result := 'Windows 98';
90: result := 'Windows ME';
end;
5:
case Win32MinorVersion of
0: result := 'Windows 2000';
1: result := 'Windows XP';
end;
6:
case Win32MinorVersion of
0: result := 'Windows Vista';
1: result := 'Windows 7';
2: result := 'Windows 8';
3: result := 'Windows 8.1';
end;
10:
case Win32MinorVersion of
0: result := 'Windows 10';
end;
end;
end;

实际上没有必要调用GetVersionEx,因为SysUtils.pasinitialization子句中有InitPlatformID。因此,全局常量 Win32MajorVersionWin32MinorVersion (和 friend )已经被填充。​​

关于delphi - 如何确定操作系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3447536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com