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); }
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); } }
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); } }
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; }
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; } } }
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); } } }
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); } } }
public override void DeleteKey(baseKey RootKey, string key) { if (IsConnected) { try { RegistryMethod.DeleteKey(connectionScope, RootKey, key); } catch (Exception err) { throw err; } } }
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); }
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); }
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; }
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); }
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); }
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; }
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); }
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); }
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); }
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); }
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; }
public abstract string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType);
public abstract ArrayList EnumerateValues(baseKey RootKey, string key);
public abstract void DeleteValue(baseKey RootKey, string key, string valueName);
public abstract void DeleteKey(baseKey RootKey, string key);
public abstract void CreateValue(baseKey RootKey, string key, string valueName, string value);
public abstract void CreateKey(baseKey RootKey, string key);
public abstract void SetValue(baseKey RootKey, string key, string valueName, string value, valueType ValueType);
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; }