识别 Windows 版本 [英] Identify Windows Editions
问题描述
我正在编写一个打印详细Windows版本信息的函数,输出可能是这样的元组:
I am writing a function which prints out detailed Windows Version informations, the output may be a tuple like this:
('32bit', 'XP', 'Professional', 'SP3', 'English')
它将支持 Windows XP 及更高版本.而且我一直坚持使用 Windows 版本,例如专业版"、家庭基本版"等.
It will be supporting Windows XP and above. And I'm stuck with getting the Windows edition, e.g., "Professional", "Home Basic", etc.
platform.win32_ver() 或 sys.getwindowsversion() 不适合我.
platform.win32_ver() or sys.getwindowsversion() doesn't do it for me.
win32api.GetVersionEx(1) 几乎命中,但看起来没有告诉我足够的信息.
win32api.GetVersionEx(1) almost hits, but looks like it doesn't tell me enough information.
然后我看到了 GetProductInfo(),但看起来它没有在 pywin32 中实现.
Then I saw GetProductInfo(), but looks like it's not implemented in pywin32.
有什么提示吗?
推荐答案
您可以使用 ctypes
访问任何 WinAPI 函数.GetProductInfo()
在 windll.kernel32.GetProductInfo
中.
You can use ctypes
to access any WinAPI function. GetProductInfo()
is in windll.kernel32.GetProductInfo
.
我找到了一个 Python 版本MSDN获取系统版本"示例.
I'd found a Python version (GPL licensed, but you can see usage of the functions there) of the MSDN "Getting the System Version" example.
这篇关于识别 Windows 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!