Esempio n. 1
0
        public static RegistryKey OpenSubKey(RegistryKey subKey, string name, WinType winType)
        {
            RegistryKey64 reg = new RegistryKey64(subKey);

            int wow6432 = (winType == WinType.x64) ? KEY_WOW64_64KEY : KEY_WOW64_32KEY;

            return(reg.OpenSubKey(name, KEY_QUERY_VALUE + wow6432));
        }
Esempio n. 2
0
        //[RegistryPermission(SecurityAction.Assert, Read = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions")]
        internal static T GetLocalMachineRegistryValue <T>(string path, string keyName, T defaultValue, WinType winType)
        {
            T local = default(T);

            RegistryKey key = null;

            //try
            //{
            key = RegistryKey64.OpenSubKey(Registry.LocalMachine, path, winType);
            //try
            //{
            //}
            //catch
            //{
            //    key = Registry.LocalMachine.OpenSubKey(path, false);
            //}

            //key = Registry.LocalMachine.OpenSubKey(path);

            if (key == null)
            {
                return(defaultValue);
            }
            object obj2 = key.GetValue(keyName);

            if (obj2 is T)
            {
                return((T)obj2);
            }
            local = defaultValue;
            //}
            //catch
            //{
            //    key.Close();
            //}


            return(local);
        }