获取Windows版本
问题说明
任何人都可以帮助我检测用户可能使用的Windows版本?
Can anyone help me detect which version of Windows the user may be using?
我已经看到一些例子来做到这一点,但是Vista / 7操作系统。
I have seen some examples to do this, but they are not updated for Vista/7 Operating Systems.
此外,检测操作系统是否在x32或x64架构上运行会很有用。
Additionally it would be useful to detect if the OS is running on x32 or x64 architecture.
正确答案
在XE2上引入了一个新课程来处理这个问题: TOSVersion
。
On XE2 a new class was introduced to deal with this: TOSVersion
.
- 读取
TOSVersion.Architecture
以检查32或64位操作系统。
- 读取
TOSVersion。平台
来检查Windows或Mac。
- 阅读
TOSVersion.Major
和
读取
TOSVersion.Name
以获取基本的产品名称,例如Windows 7。
- 读取
TOSVersion.ToString
以获取完整的产品名称,例如版本。 Windows 7 Service Pack 1(版本6.1,Build 7601,64位版本)。
- Read
TOSVersion.Architecture
to check for 32 or 64 bit OS. - Read
TOSVersion.Platform
to check for Windows or Mac. - Read
TOSVersion.Major
andTOSVersion.Minor
for version numbers. - Read
TOSVersion.Name
to obtain the basic product name, e.g. Windows 7. - Read
TOSVersion.ToString
to obtain the full product name with version, e.g. Windows 7 Service Pack 1 (Version 6.1, Build 7601, 64-bit Edition).
对于旧版本的Delphi,我推荐以下内容:
For older versions of Delphi I recommend the following:
为了检查2000,XP,Vista,7,我建议您阅读 Win32MajorVersion
和 Win32MinorVersion
。
In order to check for 2000, XP, Vista, 7 I suggest you read Win32MajorVersion
and Win32MinorVersion
.
- major.minor = 5.0 => Windows 2000
- major.minor = 5.1 => Windows XP
- major.minor = 5.2 => Windows 2003 Server或XP64
- major.minor = 6.0 => Windows Vista / 2008服务器
- major.minor = 6.1 => Windows 7/2008服务器R2
- major.minor = 5.0 => Windows 2000
- major.minor = 5.1 => Windows XP
- major.minor = 5.2 => Windows 2003 server or XP64
- major.minor = 6.0 => Windows Vista/2008 server
- major.minor = 6.1 => Windows 7/2008 server R2
相同的信息可在 MSDN ,但上述来自我的头!
The same information is available on MSDN, but the above came from my head!
如果你想要非常det产品信息不足,需要更多的工作。沃伦的回答为获得这些信息提供了一条很好的途径。如果你想要测试能力,那么版本号就可以了。
If you are wanting very detailed product information then that takes a bit more work. Warren's answer gives one good route to obtaining that information. If you are wanting to test capability then version numbers are fine.
使用 CheckWin32Version
来检查当前操作系统是否超过了某个版本级别。虽然您应该检查该函数在Delphi中是否正常工作,因为在Delphi 6及更早版本中该函数的实现是不正确的。
Use CheckWin32Version
to check if the prevailing OS exceeds a certain version level. Although you should check that the function works correctly in your Delphi since the implementation of that function in Delphi 6 and earlier was incorrect.
要了解本机操作系统架构(32或64位),请使用 GetNativeSystemInfo
功能。此功能在较旧的操作系统上不可用,因此您应该使用 GetProcAddress
显式加载它。测试 wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64
以检查64位操作系统。
To find out what the native OS architecture is (32 or 64 bit), use the GetNativeSystemInfo
function. This function is not available on older operating systems so you should load it explicitly with GetProcAddress
. Test for wProcessorArchitecture=PROCESSOR_ARCHITECTURE_AMD64
to check for 64 bit OS.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfkhcg
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20