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')
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() or sys.getwindowsversion() doesn't do it for me.
win32api.GetVersionEx(1) almost hits, but looks like it doesn't tell me enough information.
Then I saw GetProductInfo(), but looks like it's not implemented in pywin32.
Any hints?
You can use
ctypes
to access any WinAPI function.GetProductInfo()
is inwindll.kernel32.GetProductInfo
.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.
If ctypes doesn't work (due to 32 vs 64 bits?), this hack should:
Or just read the registry:
Or use this:
I tried a few of the solutions above, but I was looking for something that gave me "Windows XP" or "Windows 7". There are a few more methods in platform that expose even more information.