Example #1
0
        public static string GetValue(ManagementScope connectionScope,
                                      baseKey BaseKey,
                                      string key,
                                      string valueName,
                                      valueType ValueType)
        {
            string          typeOfValue  = RegistryMethod.ConvertGetValueType(ValueType);
            string          returnValue  = string.Empty;
            ManagementClass registryTask = new ManagementClass(connectionScope,
                                                               new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters(typeOfValue);

            methodParams["hDefKey"]     = BaseKey;
            methodParams["sSubKeyName"] = key;
            methodParams["sValueName"]  = valueName;

            ManagementBaseObject exitValue = registryTask.InvokeMethod(typeOfValue,
                                                                       methodParams, null);

            try{
                returnValue = exitValue["sValue"].ToString();
            }
            catch {
                try{ //ToDo: fix this ASAP, nested try/catch, I mean come on dude!
                    returnValue = exitValue["uValue"].ToString();
                }
                catch (SystemException e) {
                    returnValue = e.Message.ToString();
                }
            }
            return(returnValue);
        }
Example #2
0
 public override void CreateValue(baseKey RootKey, string key, string valueName, string value)
 {
     if (IsConnected)
         try
         {
             RegistryMethod.CreateValue(connectionScope, RootKey, key, valueName, value);
         }
         catch (ManagementException err)
         {
             Console.WriteLine("An error occurred: " + err.Message);
         }
 }
Example #3
0
 public override void DeleteKey(baseKey RootKey, string key)
 {
     if (IsConnected)
         try
         {
             RegistryMethod.DeleteKey(connectionScope, RootKey, key);
         }
         catch (ManagementException err)
         {
             Console.WriteLine("An error occurred: " + err.Message);
         }
 }
Example #4
0
 public override string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType)
 {
     string Value = string.Empty;
     if (IsConnected)
         try
         {
             Value = RegistryMethod.GetValue(connectionScope, RootKey, key, valueName, ValueType);
         }
         catch (ManagementException err)
         {
             Console.WriteLine("An error occurred: " + err.Message);
         }
     return Value;
 }
Example #5
0
 public override void CreateValue(baseKey RootKey, string key, string valueName, string value)
 {
     if (IsConnected)
     {
         try
         {
             RegistryMethod.CreateValue(connectionScope, RootKey, key, valueName, value);
         }
         catch (Exception err)
         {
             throw err;
         }
     }
 }
Example #6
0
 public override void DeleteKey(baseKey RootKey, string key)
 {
     if (IsConnected)
     {
         try
         {
             RegistryMethod.DeleteKey(connectionScope, RootKey, key);
         }
         catch (ManagementException err)
         {
             Console.WriteLine("An error occurred: " + err.Message);
         }
     }
 }
Example #7
0
 public override void CreateValue(baseKey RootKey, string key, string valueName, string value)
 {
     if (IsConnected)
     {
         try
         {
             RegistryMethod.CreateValue(connectionScope, RootKey, key, valueName, value);
         }
         catch (ManagementException err)
         {
             Console.WriteLine("An error occurred: " + err.Message);
         }
     }
 }
Example #8
0
 public override void DeleteKey(baseKey RootKey, string key)
 {
     if (IsConnected)
     {
         try
         {
             RegistryMethod.DeleteKey(connectionScope, RootKey, key);
         }
         catch (Exception err)
         {
             throw err;
         }
     }
 }
Example #9
0
        public static void DeleteKey(ManagementScope connectionScope,
                                     baseKey BaseKey,
                                     string key)
        {
            ManagementClass registryTask = new ManagementClass(connectionScope,
                                                               new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters("DeleteKey");

            methodParams["hDefKey"]     = BaseKey;
            methodParams["sSubKeyName"] = key;

            ManagementBaseObject exitCode = registryTask.InvokeMethod("DeleteKey",
                                                                      methodParams, null);
        }
Example #10
0
        public static void CreateKey(ManagementScope connectionScope,
            baseKey BaseKey,
            string key)
        {
            ManagementClass registryTask = new ManagementClass(connectionScope,
                           new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters("CreateKey");

            methodParams["hDefKey"] = BaseKey;
            methodParams["sSubKeyName"] = key;

            ManagementBaseObject exitCode = registryTask.InvokeMethod("CreateKey",
                                                                        methodParams, null);
        }
Example #11
0
 public override ArrayList EnumerateKeys(baseKey RootKey, string key)
 {
     ArrayList subKeys = new ArrayList();
     if (IsConnected)
         try
         {
             subKeys.AddRange(RegistryMethod.EnumerateKeys(connectionScope, RootKey, key));
         }
         catch (ManagementException err)
         {
             Console.WriteLine("An error occurred: " + err.Message);
         }
     return subKeys;
 }
Example #12
0
        public override string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType)
        {
            string Value = string.Empty;

            if (IsConnected)
            {
                try
                {
                    Value = RegistryMethod.GetValue(connectionScope, RootKey, key, valueName, ValueType);
                }
                catch (ManagementException err)
                {
                    Console.WriteLine("An error occurred: " + err.Message);
                }
            }
            return(Value);
        }
Example #13
0
        public override ArrayList EnumerateKeys(baseKey RootKey, string key)
        {
            ArrayList subKeys = new ArrayList();

            if (IsConnected)
            {
                try
                {
                    subKeys.AddRange(RegistryMethod.EnumerateKeys(connectionScope, RootKey, key));
                }
                catch (ManagementException err)
                {
                    Console.WriteLine("An error occurred: " + err.Message);
                }
            }
            return(subKeys);
        }
Example #14
0
        public static string[] EnumerateKeys(ManagementScope connectionScope,
                                             baseKey BaseKey,
                                             string key)
        {
            ManagementClass registryTask = new ManagementClass(connectionScope,
                           new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters("EnumKey");

            methodParams["hDefKey"] = BaseKey;
            methodParams["sSubKeyName"] = key;

            ManagementBaseObject exitCode = registryTask.InvokeMethod("EnumKey",
                                                        methodParams, null);
            System.String[] subKeys;
            subKeys = (string[])exitCode["sNames"];
            return subKeys;
        }
Example #15
0
        public override string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType)
        {
            string Value = string.Empty;

            if (IsConnected)
            {
                try
                {
                    Value = RegistryMethod.GetValue(connectionScope, RootKey, key, valueName, ValueType);
                }
                catch (Exception err)
                {
                    throw err;
                }
            }
            return(Value);
        }
Example #16
0
        public override ArrayList EnumerateKeys(baseKey RootKey, string key)
        {
            ArrayList subKeys = new ArrayList();

            if (IsConnected)
            {
                try
                {
                    subKeys.AddRange(RegistryMethod.EnumerateKeys(connectionScope, RootKey, key));
                }
                catch (Exception err)
                {
                    throw err;
                }
            }
            return(subKeys);
        }
Example #17
0
        public static string[] EnumerateValues(ManagementScope connectionScope,
                                               baseKey BaseKey,
                                               string key)
        {
            ManagementClass registryTask = new ManagementClass(connectionScope,
                                                               new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters("EnumValues");

            methodParams["hDefKey"]     = BaseKey;
            methodParams["sSubKeyName"] = key;

            ManagementBaseObject exitCode = registryTask.InvokeMethod("EnumValues",
                                                                      methodParams, null);

            System.String[] values;
            values = (string[])exitCode["sNames"];
            return(values);
        }
Example #18
0
        public static void SetValue(ManagementScope connectionScope,
                                    baseKey BaseKey,
                                    string key,
                                    string valueName,
                                    string value,
                                    valueType ValueType)
        {
            string          typeOfValue  = RegistryMethod.ConvertSetValueType(ValueType);
            string          returnValue  = string.Empty;
            ManagementClass registryTask = new ManagementClass(connectionScope,
                                                               new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters(typeOfValue);

            methodParams["hDefKey"]     = BaseKey;
            methodParams["sSubKeyName"] = key;
            methodParams["sValueName"]  = valueName;
            methodParams["sValue"]      = value;

            ManagementBaseObject exitValue = registryTask.InvokeMethod(typeOfValue,
                                                                       methodParams, null);
        }
Example #19
0
        public static List <string> EnumerateKeys(ManagementScope connectionScope,
                                                  baseKey BaseKey,
                                                  string key)
        {
            ManagementClass registryTask = new ManagementClass(connectionScope,
                                                               new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters("EnumKey");

            methodParams["hDefKey"]     = BaseKey;
            methodParams["sSubKeyName"] = key;
            List <string> subKeys = new List <string>();

            try
            {
                ManagementBaseObject exitCode = registryTask.InvokeMethod("EnumKey",
                                                                          methodParams, null);
                subKeys = new List <string>((string[])exitCode["sNames"]);
            }
            catch (Exception ex)
            {
                var message = ex.Message;
            }

            return(new List <string>(subKeys));
            //var HKLM32 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machinename, RegistryView.Registry32);
            //var HKLM64 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machinename, RegistryView.Registry64);

            //RegistryKey OurKey32 = Microsoft.Win32.Registry.LocalMachine;
            //RegistryKey OurKey64 = Microsoft.Win32.Registry.LocalMachine;
            //OurKey32 = HKLM32.OpenSubKey(key, false);
            //OurKey64 = HKLM64.OpenSubKey(key, false);
            //var list = GetSubKeys(OurKey32);
            //var list2 = GetSubKeys(OurKey64);
            ////list.AddRange(list2);
            //return list;
        }
Example #20
0
 public abstract string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType);
Example #21
0
 public abstract ArrayList EnumerateValues(baseKey RootKey, string key);
Example #22
0
 public abstract void DeleteValue(baseKey RootKey, string key, string valueName);
Example #23
0
 public abstract void DeleteKey(baseKey RootKey, string key);
Example #24
0
 public abstract void CreateValue(baseKey RootKey, string key, string valueName, string value);
Example #25
0
 public abstract void CreateKey(baseKey RootKey, string key);
Example #26
0
 public abstract void CreateKey(baseKey RootKey, string key);
Example #27
0
 public abstract void SetValue(baseKey RootKey, string key, string valueName, string value, valueType ValueType);
Example #28
0
 public abstract void CreateValue(baseKey RootKey, string key, string valueName, string value);
Example #29
0
 public abstract void DeleteValue(baseKey RootKey, string key, string valueName);
Example #30
0
        public static string GetValue(ManagementScope connectionScope,
            baseKey BaseKey,
            string key,
            string valueName,
            valueType ValueType)
        {
            string typeOfValue = RegistryMethod.ConvertGetValueType(ValueType);
            string returnValue = string.Empty;
            ManagementClass registryTask = new ManagementClass(connectionScope,
                           new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters(typeOfValue);

            methodParams["hDefKey"] = BaseKey;
            methodParams["sSubKeyName"] = key;
            methodParams["sValueName"] = valueName;

            ManagementBaseObject exitValue = registryTask.InvokeMethod(typeOfValue,
                                                                     methodParams, null);
            try{
                returnValue = exitValue["sValue"].ToString();
            }
            catch{
                try{ //ToDo: fix this ASAP, nested try/catch, I mean come on dude!
                    returnValue = exitValue["uValue"].ToString();
                }
                catch (SystemException e){
                    returnValue = e.Message.ToString();
                }
            }
            return returnValue;
        }
Example #31
0
 public abstract void DeleteKey(baseKey RootKey, string key);
Example #32
0
 public abstract ArrayList EnumerateValues(baseKey RootKey, string key);
Example #33
0
        public static void SetValue(ManagementScope connectionScope,
            baseKey BaseKey,
            string key,
            string valueName,
            string value,
            valueType ValueType)
        {
            string typeOfValue = RegistryMethod.ConvertSetValueType(ValueType);
            string returnValue = string.Empty;
            ManagementClass registryTask = new ManagementClass(connectionScope,
                           new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters(typeOfValue);

            methodParams["hDefKey"] = BaseKey;
            methodParams["sSubKeyName"] = key;
            methodParams["sValueName"] = valueName;
            methodParams["sValue"] = value;

            ManagementBaseObject exitValue = registryTask.InvokeMethod(typeOfValue,
                                                                     methodParams, null);
        }