private static int?GetDWord(string keyPath, string subkeyName, string valueName) { int?returnValue = null; if (!string.IsNullOrEmpty(subkeyName)) { keyPath = System.IO.Path.Combine(keyPath, subkeyName); } System.Security.AccessControl.RegistryRights rights = System.Security.AccessControl.RegistryRights.QueryValues; RegistryKey settingsKey = rootRegistryKey.OpenSubKey(keyPath, RegistryKeyPermissionCheck.ReadSubTree, rights); /* RegistryKey settingsKey = rootRegistryKey.OpenSubKey(keyPath, false); */ if (settingsKey != null) { object regValue = settingsKey.GetValue(valueName); if (regValue != null) { returnValue = Convert.ToInt32(regValue); } settingsKey.Close(); } return(returnValue); }
/// <summary> /// Gets the value of a multi-string stored in the registry. /// </summary> /// <param name="keyPath"> /// The path of the registry key that contains the data to be read. /// </param> /// <param name="subkeyName"> /// An optional relative path of a subkey in which the data is stored. /// </param> /// <param name="valueName"> /// The name of the value to be retrieved from the registry. /// </param> /// <returns> /// Returns the value of the multi-string from the registry. /// If there is a problem retrieving the specified value from the registry, null is returned. /// </returns> private static string[] GetMultiString(string keyPath, string subkeyName, string valueName) { string[] returnValue = null; if (!string.IsNullOrEmpty(subkeyName)) { keyPath = System.IO.Path.Combine(keyPath, subkeyName); } System.Security.AccessControl.RegistryRights rights = System.Security.AccessControl.RegistryRights.QueryValues; RegistryKey settingsKey = rootRegistryKey.OpenSubKey(keyPath, RegistryKeyPermissionCheck.ReadSubTree, rights); if (settingsKey != null) { object regValue = settingsKey.GetValue(valueName, null); if (regValue != null) { returnValue = (string[])regValue; } settingsKey.Close(); } return(returnValue); }
private void button2_Click(object sender, EventArgs e) { //Write a new lecence key from textbox to registry string tlicence = ""; string newlicence = textBox1.Text; string[] slicence = newlicence.Split(';'); Byte[] licnew = new Byte[slicence.Length - 1]; for (int i = 0; i < slicence.Length - 1; ++i) { licnew[i] = Convert.ToByte(slicence[i], 16); tlicence += (char)licnew[i]; } textBox2.ScrollBars = ScrollBars.Vertical; textBox2.Multiline = true; try { System.Security.AccessControl.RegistryRights rights = System.Security.AccessControl.RegistryRights.FullControl; RegistryKeyPermissionCheck check = RegistryKeyPermissionCheck.ReadWriteSubTree; RegistryKey safekey; safekey = Registry.CurrentUser.OpenSubKey(ourkey, check, rights); if (safekey == null) { safekey = Registry.CurrentUser.CreateSubKey(ourkey); } safekey.SetValue(ourkey, licnew); safekey.Close(); textBox2.Text = "echo " + "\"" + newlicence + "\"" + " | hostlist.exe -read -r"; } catch (Exception prob) { using (FileStream stream = new FileStream(ourkeyfile, FileMode.Create)) { using (BinaryWriter writer = new BinaryWriter(stream)) { writer.Write(licnew); writer.Close(); } } textBox2.Text = "hostlist -r < " + ourkeyfile; } }
public Microsoft.Win32.RegistryKey OpenSubKey(string name, System.Security.AccessControl.RegistryRights rights) { return(default(Microsoft.Win32.RegistryKey)); }
public RegistryAuditRule(string identity, System.Security.AccessControl.RegistryRights registryRights, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AuditFlags flags) : base(default(System.Security.Principal.IdentityReference), default(int), default(bool), default(System.Security.AccessControl.InheritanceFlags), default(System.Security.AccessControl.PropagationFlags), default(System.Security.AccessControl.AuditFlags)) { }
public RegistryAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.RegistryRights registryRights, System.Security.AccessControl.AccessControlType type) : base(default(System.Security.Principal.IdentityReference), default(int), default(bool), default(System.Security.AccessControl.InheritanceFlags), default(System.Security.AccessControl.PropagationFlags), default(System.Security.AccessControl.AccessControlType)) { }
public Microsoft.Win32.RegistryKey? OpenSubKey(string name, System.Security.AccessControl.RegistryRights rights) { throw null; }
public Microsoft.Win32.RegistryKey OpenSubKey(string name, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, System.Security.AccessControl.RegistryRights rights) { throw null; }
public RegistryKey OpenSubKey(string name, RegistryKeyPermissionCheck permissionCheck, System.Security.AccessControl.RegistryRights rights) { return(default(RegistryKey)); }
public IRegistryKey OpenSubKey(string name, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, System.Security.AccessControl.RegistryRights rights) { return((RegistryKey)_regKey.OpenSubKey(name, permissionCheck, rights)); }
public RegistryAccessRule(IdentityReference identity, System.Security.AccessControl.RegistryRights registryRights, AccessControlType type) : this(identity, (int)registryRights, false, InheritanceFlags.None, PropagationFlags.None, type) { }
public RegistryAccessRule(string identity, System.Security.AccessControl.RegistryRights registryRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type) : this(new NTAccount(identity), (int)registryRights, false, inheritanceFlags, propagationFlags, type) { }
public RegistryAuditRule(IdentityReference identity, System.Security.AccessControl.RegistryRights registryRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags) : this(identity, (int)registryRights, false, inheritanceFlags, propagationFlags, flags) { }
private void button1_Click(object sender, EventArgs e) { //Get the licence key for safeqp.dll from the registry and display in hex form textBox2.ScrollBars = ScrollBars.None; textBox2.Multiline = false; Byte[] lic = null; try { System.Security.AccessControl.RegistryRights rights = System.Security.AccessControl.RegistryRights.FullControl; RegistryKeyPermissionCheck check = RegistryKeyPermissionCheck.ReadWriteSubTree; RegistryKey safekey; safekey = Registry.CurrentUser.OpenSubKey(ourkey, check, rights); if (safekey != null) { lic = (Byte[])safekey.GetValue(ourkey); if (lic == null) { throw new Exception("No lic"); } safekey.Close(); } } catch (Exception prob) { if (textBox2.Text != "") { ourkeyfile = textBox2.Text; } using (FileStream stream = new FileStream(ourkeyfile, FileMode.OpenOrCreate)) { using (BinaryReader reader = new BinaryReader(stream)) { lic = new Byte[20]; reader.Read(lic, 0, 20); reader.Close(); } } } if (lic != null) { string licence = ""; string tlicence = ""; for (int i = 0; i < lic.Length; ++i) { licence += string.Format("{0:x2};", lic[i]); tlicence += (char)lic[i]; } textBox2.Multiline = true; textBox2.ScrollBars = ScrollBars.Vertical; textBox1.Text = licence; textBox2.Text = tlicence; string ll2 = licence.Replace(';', ','); textBox2.Text += "\n\r\n\r\n\rWindows Registry Editor Version 5.00"; textBox2.Text += "\n"; textBox2.Text += "\n[HKEY_LOCAL_MACHINE\\Software\\safeqp]"; textBox2.Text += "\n\"Software\\\\safeqp\"=hex:" + ll2; textBox2.Text += "\n"; textBox2.Text += "\n[HKEY_CURRENT_USER\\Software\\safeqp]"; textBox2.Text += "\n\"Software\\\\safeqp\"=hex:" + ll2; } }