AGS.Editor.SpriteSelector.GetAssociatedProgramForFileExtension C# (CSharp) Метод

GetAssociatedProgramForFileExtension() приватный Метод

private GetAssociatedProgramForFileExtension ( string extension ) : string
extension string
Результат string
        private string GetAssociatedProgramForFileExtension(string extension)
        {
            RegistryKey key = Registry.ClassesRoot.OpenSubKey(extension);
            if (key != null)
            {
                string fileHandlerType = key.GetValue(null).ToString();
                key.Close();
                key = Registry.ClassesRoot.OpenSubKey(fileHandlerType + @"\shell\open\command");
                if (key != null)
                {
                    string launchPath = key.GetValue(null).ToString();
                    key.Close();
                    if (launchPath.StartsWith("\""))
                    {
                        launchPath = launchPath.Substring(1);
                        int endIndex = launchPath.IndexOf("\"");
                        if (endIndex > 0)
                        {
                            launchPath = launchPath.Substring(0, endIndex);
                        }
                    }
                    else if (launchPath.Contains(" "))
                    {
                        launchPath = launchPath.Substring(0, launchPath.IndexOf(' '));
                    }
                    return launchPath;
                }
            }
            throw new AGSEditorException("No default application registered to handle file type " + extension);
        }