Retrieving Windows version “1511”

前端 未结 2 510
青春惊慌失措
青春惊慌失措 2020-12-16 07:56

The latest release of Windows 10 (currently Insider Preview) is badged as:

Version 1511 (OS Build 10586.3)

when looking in \"Abo

2条回答
  •  攒了一身酷
    2020-12-16 08:28

    FWIW, Process Monitor suggests that winver does simply query ReleaseId. So maybe that is indeed all there is to the "Version 1511" branding.

    23:59:30,6022870    winver.exe  7004    RegQueryValue   HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseID SUCCESS Type: REG_SZ, Length: 10, Data: 1511
    

    Changing the registry value to something random is immediately reflected when launching winver again. Removing the value makes winver show an empty string.

    So, while not nicely wrapped in an API and possibly unsupported, this seems to do the trick for now:

    using (var hklmKey = Microsoft.Win32.Registry.LocalMachine)
    using (var subKey = hklmKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"))
    {
         if (subKey != null)
         {
             string release = subKey.GetValue("ReleaseId") as string;
    
             if (release != null)
                 retVal += " Version " + release;
         }
    }
    

提交回复
热议问题