sistema operativo obtener informacion c# windows operating-system caption

operativo - obtener informacion del sistema c#



Obtenga la versiĆ³n del sistema operativo/nombre descriptivo en C# (6)

Agregue una referencia de .NET a Microsoft.VisualBasic. Luego llame:

new Microsoft.VisualBasic.Devices.ComputerInfo().OSFullName

Desde MSDN :

Esta propiedad devuelve información detallada sobre el nombre del sistema operativo si Windows Management Instrumentation (WMI) está instalado en la computadora. De lo contrario, esta propiedad devuelve la misma cadena que la propiedad My.Computer.Info.OSPlatform , que proporciona información menos detallada que la que WMI puede proporcionar. Información que WMI puede proporcionar.

Actualmente estoy trabajando en un proyecto C #. Quiero recopilar estadísticas de usuarios para desarrollar mejor el software. Estoy usando la característica Environment.OS de C # pero solo muestra el nombre del SO como algo parecido a Microsoft Windows NT

Lo que quiero recuperar es el nombre real del sistema operativo, como Windows XP, Windows Vista or Windows 7 etc.

es posible?


Agregue una referencia y use sentencias para System.Management , luego:

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; }


Deberías tratar de evitar WMI para uso local. Es muy conveniente, pero pagas caro por ello en términos de rendimiento. ¡Piensa en el impuesto a la pereza!

La respuesta de Kashish sobre el registro no funciona en todos los sistemas. El siguiente código debe incluir también el paquete de servicio:

public string HKLM_GetString(string path, string key) { try { RegistryKey rk = Registry.LocalMachine.OpenSubKey(path); if (rk == null) return ""; return (string)rk.GetValue(key); } catch { return ""; } } public string FriendlyName() { string ProductName = HKLM_GetString(@"SOFTWARE/Microsoft/Windows NT/CurrentVersion", "ProductName"); string CSDVersion = HKLM_GetString(@"SOFTWARE/Microsoft/Windows NT/CurrentVersion", "CSDVersion"); if (ProductName != "") { return (ProductName.StartsWith("Microsoft") ? "" : "Microsoft ") + ProductName + (CSDVersion != "" ? " " + CSDVersion : ""); } return ""; }


String subKey = @"SOFTWARE/Wow6432Node/Microsoft/Windows NT/CurrentVersion"; RegistryKey key = Registry.LocalMachine; RegistryKey skey = key.OpenSubKey(subKey); Console.WriteLine("OS Name: {0}", skey.GetValue("ProductName"));

Espero que encuentres esto útil


System.OperatingSystem osInfo = System.Environment.OSVersion;


public int OStype() { int os = 0; IEnumerable<string> list64 = Directory.GetDirectories(Environment.GetEnvironmentVariable("SystemRoot")).Where(s => s.Equals(@"C:/Windows/SysWOW64")); IEnumerable<string> list32 = Directory.GetDirectories(Environment.GetEnvironmentVariable("SystemRoot")).Where(s => s.Equals(@"C:/Windows/System32")); if (list32.Count() > 0) { os = 32; if (list64.Count() > 0) os = 64; } return os; }