/// <summary>
        ///
        /// </summary>
        /// <param name="icon"></param>
        protected void SetDefaultIcon(ProgramIcon icon)
        {
            if (!this.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            if (icon != ProgramIcon.None)
            {
                // registryWrapper.Write(this.progId, "DefaultIcon", icon.ToString());

                RegistryKey root   = Registry.ClassesRoot;
                RegistryKey key    = root.OpenSubKey(this.progId, true);
                RegistryKey tmpKey = key.OpenSubKey("DefaultIcon", true);

                if (tmpKey != null)
                {
                    key.DeleteSubKeyTree("DefaultIcon");
                }

                tmpKey = key.CreateSubKey("DefaultIcon");
                tmpKey.SetValue(string.Empty, icon.ToString(), RegistryValueKind.ExpandString);

                ShellNotification.NotifyOfChange();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="icon"></param>
        protected void SetDefaultIcon(ProgramIcon icon)
        {
            if (!this.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            if (icon != ProgramIcon.None)
            {
                registryWrapper.Write(this.progId, "DefaultIcon", icon.ToString());

                ShellNotification.NotifyOfChange();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected ProgramIcon GetDefaultIcon()
        {
            if (!this.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            object val = registryWrapper.Read(this.progId + "\\DefaultIcon", "");

            if (val == null)
            {
                return(ProgramIcon.None);
            }

            return(ProgramIcon.Parse(val.ToString()));
        }
Example #4
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %L"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, string extension, ProgramIcon icon = null)
        {
            FileAssociationInfo fai = new FileAssociationInfo(extension);

              if (!fai.Exists)
              fai.Create(progId);

              fai.ProgID = progId;

              ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

              if (!pai.Exists)
              pai.Create();

              pai.AddVerb(new ProgramVerb("open", executablePath));
              if (icon != null)
            pai.DefaultIcon = icon;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="icon"></param>
        protected void SetDefaultIcon(ProgramIcon icon)
        {
            if (!this.Exists)
            throw new Exception("Extension does not exist");

             if (icon != ProgramIcon.None)
             {
             registryWrapper.Write(this.progId + "\\DefaultIcon", "", icon.ToString());

            ShellNotification.NotifyOfChange();
             }
        }
Example #6
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %L"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, string extension, ProgramIcon icon = null)
        {
            FileAssociationInfo fai = new FileAssociationInfo(extension);

            if (!fai.Exists)
            {
                fai.Create(progId);
            }

            fai.ProgID = progId;

            ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

            if (!pai.Exists)
            {
                pai.Create();
            }

            pai.AddVerb(new ProgramVerb("open", executablePath));
            if (icon != null)
            {
                pai.DefaultIcon = icon;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="icon"></param>
        protected void SetDefaultIcon(ProgramIcon icon)
        {
            if (!this.Exists)
            throw new Exception("Extension does not exist");

             if (icon != ProgramIcon.None)
             {
            // registryWrapper.Write(this.progId, "DefaultIcon", icon.ToString());

            RegistryKey root = Registry.ClassesRoot;
            RegistryKey key = root.OpenSubKey(this.progId, true);
            RegistryKey tmpKey = key.OpenSubKey("DefaultIcon", true);

            if (tmpKey != null)
            {
                key.DeleteSubKeyTree("DefaultIcon");
            }

            tmpKey = key.CreateSubKey("DefaultIcon");
            tmpKey.SetValue(string.Empty, icon.ToString(), RegistryValueKind.ExpandString);

            ShellNotification.NotifyOfChange();
             }
        }