查询Windows 10各版本对应的注册表EditionID键取值
Windows 10 主流版本对应EditionID取值
- Windows 10 Home:
Core - Windows 10 Pro:
Professional - Windows 10 Pro for Workstations:
ProfessionalWorkstation - Windows 10 Education:
Education - Windows 10 Pro Education:
ProfessionalEducation - Windows 10 Enterprise:
Enterprise - Windows 10 Enterprise LTS/LTSC/LTSB 全版本:
EnterpriseS
代码优化说明
你现有代码在32位程序运行在64位系统上时,会因为注册表自动重定向读取不到正确路径的键值,同时需要补充空值判断避免空引用异常,优化后参考代码如下:
// 优先读取64位注册表,避免32位程序重定向问题 using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) using (var key = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion")) { if (key != null) { var keyValue = key.GetValue("EditionID"); string osEdition = keyValue?.ToString() ?? string.Empty; // 后续业务逻辑 } }
内容的提问来源于stack exchange,提问作者RBT
相关产品推荐
相关产品推荐

