System.Environment.OSVersion does not appear to indicate which Edition of Windows 2003 is installed (Standard, Enterprise, DataCenter).
Is there any way to access this information using managed code only?
I know I can use P/Invoke to call GetVersionEx and examine OSVERSIONINFOEX.wSuiteMask to get this info, but I'm looking for a simpler solution.
Update
Using WMI looks like the way to go, though the OSProductSuite property of Win32_OperatingSystem looks more reliable than the Name property. Here's sample code:
ManagementScope scope = new ManagementScope();
ObjectQuery query = new ObjectQuery("SELECT name, csdversion, description, OperatingSystemSKU, OSProductSuite FROM Win32_OperatingSystem");
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query))
{
using (ManagementObjectCollection resultCollection = searcher.Get())
{
foreach (ManagementObject result in resultCollection)
{
foreach (PropertyData propertyData in result.Properties)
{
Debug.WriteLine(
propertyData.Name + ": " +
((propertyData.Value == null) ? "" : propertyData.Value.ToString())
);
}
}
}
}