Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>

        public WowRegistryKey OpenSubKey(string name)
        {
            WowRegistryKey key = null;
            IntPtr         hKey;

            if (regKey == null)
            {
                int samFlags = WowRegistry.KEY_QUERY_VALUE | WowRegistry.KEY_ENUMERATE_SUB_KEYS;

                // [SMC 20090811] Since WowRegistry is taking care of opening the proper key
                // we shouldn't need to redirect again here...

                //if (redirected)
                //    samFlags |= WowRegistry.KEY_WOW64_64KEY;
                //else
                //    samFlags |= WowRegistry.KEY_WOW64_32KEY;

                if (WowRegistry.ForceRedirection)
                {
                    samFlags |= WowRegistry.KEY_WOW64_32KEY;
                }

                int result = WowRegistry.RegOpenKeyEx(
                    this.intKey,
                    name,
                    0,
                    samFlags,
                    out hKey);

                if (result != WowRegistry.ERR_KEY_NOT_FOUND)
                {
                    if (result != 0)
                    {
                        throw new Exception(
                                  String.Format("WowRegistryKey.OpenSubKey(), error={0}", result));
                    }

                    key = new WowRegistryKey(hKey, null, this.hive, name);
                }
            }
            else
            {
                RegistryKey subKey = regKey.OpenSubKey(name);

                if (subKey != null)
                {
                    string subName = this.name + "\\" + name;

                    hKey = new IntPtr(subKey.GetHashCode());
                    key  = new WowRegistryKey(hKey, subKey, this.hive, subName);
                }
            }

            return(key);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>

        public WowRegistryKey OpenSubKey(string name)
        {
            WowRegistryKey key = null;
            IntPtr         hKey;

            if (regKey == null)
            {
                int samFlags = WowRegistry.KEY_QUERY_VALUE | WowRegistry.KEY_ENUMERATE_SUB_KEYS;
                if (redirected)
                {
                    samFlags |= WowRegistry.KEY_WOW64_64KEY;
                }
                else
                {
                    samFlags |= WowRegistry.KEY_WOW64_32KEY;
                }

                int result = WowRegistry.RegOpenKeyEx(
                    this.intKey,
                    name,
                    0,
                    samFlags,
                    out hKey);

                if (result != WowRegistry.ERR_KEY_NOT_FOUND)
                {
                    if (result != 0)
                    {
                        throw new Exception(
                                  String.Format("WowRegistryKey.OpenSubKey(), error={0}", result));
                    }

                    key = new WowRegistryKey(hKey, null, this.hive, name);
                }
            }
            else
            {
                RegistryKey subKey = regKey.OpenSubKey(name);

                if (subKey != null)
                {
                    string subName = this.name + "\\" + name;

                    hKey = new IntPtr(subKey.GetHashCode());
                    key  = new WowRegistryKey(hKey, subKey, this.hive, subName);
                }
            }

            return(key);
        }