如何显示基于C#的完整Windows 10版本?
我当前正在使用Environment.OSVersion.VersionString
,但没有显示完整的内部版本号
结果:
Microsoft Windows NT 10.0.17134.0
但是我想要最后一个数字,我的完整版本:10.0.17134。 228
我想知道如何显示最后一个遗漏的号码。不仅在哪里找到号码。要获取它的C#代码。
答案 0 :(得分:3)
您可以在以下找到最后一个遗失的号码
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ UBR
(这是DWORD值。在某些Windows版本中可能会丢失。)
答案 1 :(得分:3)
按HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
键的UBR
中的Windows 10内部版本号is stored in the registry。
在代码中获取代码的方法如下:
using Microsoft.Win32;
// ...
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
var buildNumber = registryKey.GetValue("UBR").ToString();
编辑:修复了值名称,以获取正确的OP编号。归功于Jorge Aguiar的正确钥匙。
答案 2 :(得分:0)
您必须组合这两个值才能获得“ OS build”:
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
var _UBR = registryKey.GetValue("UBR").ToString();
var _CurrentBuild = registryKey.GetValue("CurrentBuild").ToString();
string _version = _CurrentBuild+"."+ _UBR;
答案 3 :(得分:0)
获得您想要的东西的俗气方式:
Process.Start(new ProcessStartInfo
{
FileName = @"C:\Windows\System32\cmd.exe",
Arguments = "/c ver",
RedirectStandardOutput = true,
UseShellExecute = false
}).StandardOutput.ReadToEnd().Trim();
返回如下字符串:
Microsoft Windows [版本 10.0.19043.1052]