ARCed.Helpers.FileAssociator.Associate C# (CSharp) Метод

Associate() публичный статический Метод

Associate file extension with progID, description, icon and application
public static Associate ( string extension, string description, string icon, string application ) : void
extension string Extension to associate
description string Description of file type
icon string Path to icon to set for the file type
application string Path to icon to associate with this file type
Результат void
        public static void Associate(string extension, string description, string icon, string application)
        {
            var registryKey = Registry.ClassesRoot.CreateSubKey(extension);
            if (registryKey != null)
                registryKey.SetValue("", PROGRAM_ID);
            if (string.IsNullOrEmpty(PROGRAM_ID)) return;
            using (var key = Registry.ClassesRoot.CreateSubKey(PROGRAM_ID))
            {
                if (key == null) return;
                if (description != null)
                    key.SetValue("", description);
                if (icon != null)
                {
                    var subKey = key.CreateSubKey("DefaultIcon");
                    if (subKey != null)
                        subKey.SetValue("", ToShortPathName(icon));
                }
                if (application == null) return;
                var regKey = key.CreateSubKey(@"Shell\Open\Command");
                if (regKey != null)
                    regKey.SetValue("", ToShortPathName(application) + " \"%1\"");
            }
        }