I am currently working on a C# project. I want to collect users statistics to better develop the software. I am using the Environment.OS
feature of C# but its only showing the OS name as something like Microsoft Windows NT
What I want to be able to retrieve is the actual known name of the OS like whether it is Windows XP, Windows Vista or Windows 7
and etc.
Is this possible?
Add a reference and using statements for System.Management
, then:
public static string GetOSFriendlyName()
{
string result = string.Empty;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
foreach (ManagementObject os in searcher.Get())
{
result = os["Caption"].ToString();
break;
}
return result;
}