Exemple #1
0
        internal void Write <T>(string property, T val)
        {
            var key = BaseKey.OpenSubKey(SubKeyName, true) ?? BaseKey.CreateSubKey(SubKeyName);

            key.SetValue(property, val);
            key.Close();
        }
Exemple #2
0
        public static void SetWeakFileAssociation(string Extension, string KeyName, string OpenWith, string FileDescription, bool Unset = false)
        {
            RegistryKey BaseKey;
            RegistryKey OpenMethod;
            RegistryKey Shell;

            BaseKey = Registry.CurrentUser.CreateSubKey("Software\\Classes\\" + Extension, RegistryKeyPermissionCheck.ReadWriteSubTree);
            if (!Unset)
            {
                BaseKey.CreateSubKey("OpenWithProgids").SetValue(KeyName, "");
                OpenMethod = Registry.CurrentUser.CreateSubKey("Software\\Classes\\" + KeyName);
                OpenMethod.SetValue("", FileDescription);
                Shell = OpenMethod.CreateSubKey("Shell");
                Shell.CreateSubKey("open").CreateSubKey("command").SetValue("", "\"" + OpenWith + "\"" + " \"%1\"");
                OpenMethod.Close();
                Shell.Close();
            }
            else
            {
                RegistryKey ProgIds = BaseKey.OpenSubKey("OpenWithProgids", true);
                if (ProgIds != null)
                {
                    ProgIds.DeleteValue(KeyName, false);
                }
                Registry.CurrentUser.OpenSubKey("Software\\Classes\\", true).DeleteSubKeyTree(KeyName, false);
                ProgIds.Close();
            }
            BaseKey.Close();

            // Tell explorer the file association has been changed
            SHChangeNotify(0x08000000, 0x0000, IntPtr.Zero, IntPtr.Zero);
        }
Exemple #3
0
        public override void create()
        {
            RegistryKey key = BaseKey.CreateSubKey(Path);

            key.SetValue(Name, Value);
            key.Close();
        }
Exemple #4
0
 public override void delete()
 {
     if (Name != "")
     {
         RegistryKey key = BaseKey.CreateSubKey(Path);
         key.DeleteValue(Name);
         key.Close();
     }
     else
     {
         BaseKey.DeleteSubKey(Path);
     }
 }