예제 #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);
        }
예제 #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);
         }
 }
예제 #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);
         }
 }
예제 #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;
 }
예제 #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;
         }
     }
 }
예제 #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);
         }
     }
 }
예제 #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);
         }
     }
 }
예제 #8
0
 public override void DeleteKey(baseKey RootKey, string key)
 {
     if (IsConnected)
     {
         try
         {
             RegistryMethod.DeleteKey(connectionScope, RootKey, key);
         }
         catch (Exception err)
         {
             throw err;
         }
     }
 }
예제 #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);
        }
예제 #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);
        }
예제 #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;
 }
예제 #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);
        }
예제 #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);
        }
예제 #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;
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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;
        }
예제 #20
0
 public abstract string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType);
예제 #21
0
 public abstract ArrayList EnumerateValues(baseKey RootKey, string key);
예제 #22
0
 public abstract void DeleteValue(baseKey RootKey, string key, string valueName);
예제 #23
0
 public abstract void DeleteKey(baseKey RootKey, string key);
예제 #24
0
 public abstract void CreateValue(baseKey RootKey, string key, string valueName, string value);
예제 #25
0
 public abstract void CreateKey(baseKey RootKey, string key);
예제 #26
0
 public abstract void CreateKey(baseKey RootKey, string key);
예제 #27
0
 public abstract void SetValue(baseKey RootKey, string key, string valueName, string value, valueType ValueType);
예제 #28
0
 public abstract void CreateValue(baseKey RootKey, string key, string valueName, string value);
예제 #29
0
 public abstract void DeleteValue(baseKey RootKey, string key, string valueName);
예제 #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;
        }
예제 #31
0
 public abstract void DeleteKey(baseKey RootKey, string key);
예제 #32
0
 public abstract ArrayList EnumerateValues(baseKey RootKey, string key);
예제 #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);
        }