Example #1
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);
        }