Is there any easy开发者_如何学Python way to get Windows Edition (Home, Professional, etc.)?
Couple of ways of doing this:
- You could parse the
caption
field of theWin32_OperatingSystem
class in WMI. - You could look at
OSProductSuite
andOperatingSystemSKU
fields in theWin32_OperatingSystem
class in WMI. - You could port this C++ program using P/Invoke.
If you reference the Microsoft.VisualBasic.Devices namespace you can do this:
ComputerInfo computerInfo = new ComputerInfo();
string fullName = computerInfo.OSFullName; // i.e. "Microsoft Windows 7 Ultimate"
You can use Microsoft.VisualBasic in your c# apps - it's just like any other library.
Easy answer? Just look in the registry.
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CSDVersion
It doesn't have the overhead of WMI (50ms every call), and it gives the full name.
精彩评论