Ejemplo n.º 1
0
        /// <summary>
        /// //获取32位或64系统注册表的值。
        /// </summary>
        /// <param name="rh">根级别的名称,如Registry.LocalMachine</param>
        /// <param name="keyName">不包括根级别的名称,如:@"SOFTWARE\Microsoft\Office\12.0\Word\InstallRoot\"</param>
        /// <param name="valueName">不包括根级别的名称,如:Path</param>
        /// <returns>若没有找到,返回null</returns>
        public static string GetRegistryValue(RegistryHive rh, string keyName, string valueName)
        {
            try
            {
                object value = null;

                if (SystemHelper.Is32System())
                {
                    value = RegeditHelper.GetValueWithRegView(rh, keyName, valueName, RegistryView.Registry32);
                }
                else if (SystemHelper.Is64System())
                {
                    value = RegeditHelper.GetValueWithRegView(rh, keyName, valueName, RegistryView.Registry64);
                }

                if (value != null)
                {
                    return(value.ToString());
                }
            }
            catch (Exception ex)
            {
                throw new Exception("读取注册表失败," + ex.Message);
            }

            return(null);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 可获得NT系列的系统版本,如:xp,2000,2003,2008,vista,win7。
 /// </summary>
 /// <returns></returns>
 public static string GetWinNTSystemVersion()
 {
     return(RegeditHelper.GetRegistryValue(RegistryHive.LocalMachine, @"Software\\Microsoft\\Windows NT\\CurrentVersion", "ProductName"));
 }