public RegistryKeyClass(string registryPath, EActivationParameter enableFunction, string allowText, RegistryValueKind valueKind, ERegistryHkey hkey)
        {
            SetHKeyFormat(registryPath, hkey);

            if (!RegisterKeyAvailable)
            {
                CreateMissingSubKey(registryPath, hkey);
            }

            if (RegisterKeyAvailable)
            {
                object registryKeyValue = this.RegistryKey.GetValue(allowText);

                if ((int?)registryKeyValue == null)
                {
                    this.SetRKValue(allowText, enableFunction, valueKind);
                }
                else
                {
                    switch (enableFunction)
                    {
                    case EActivationParameter.Off:
                        this.SetRKValue(allowText, (int)EActivationParameter.Off);
                        break;

                    case EActivationParameter.On:
                        this.SetRKValue(allowText, (int)EActivationParameter.On);
                        break;

                    case EActivationParameter.AdditionalSetting1:
                        this.SetRKValue(allowText, (int)EActivationParameter.AdditionalSetting1);
                        break;

                    case EActivationParameter.AdditionalSetting2:
                        this.SetRKValue(allowText, (int)EActivationParameter.AdditionalSetting2);
                        break;
                    }
                }
            }
        }
Example #2
0
 public static RegistryKeyClass Create(string hkeyPath, EActivationParameter enableFunction, string allowText, RegistryValueKind valueKind, ERegistryHkey hkey = ERegistryHkey.LOCALMACHINE)
 {
     return(new RegistryKeyClass(hkeyPath, enableFunction, allowText, valueKind, hkey));
 }