<p>How to determine the applications associated with a particular extension (e.g. .JPG) and then determine where the executable to that application is located so that it can be launched via a call to say System.Diagnostics.Process.Start(...).</p>

<p>I already know how to read and write to the registry.  It is the layout of the registry that makes it harder to determine in a standard way what applications are associated with an extension, what are there display names, and where their executables are located.</p>

[{'answer_id': 24956, 'author': 'Erik Öjebo', 'author_id': 276, 'author_profile': 'https://Stackoverflow.com/users/276', 'pm_score': -1, 'selected': False, 'text': '<p>The file type associations are stored in the Windows registry, so you should be able to use the <a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx#Mtps_DropDownFilterText" rel="nofollow noreferrer">Microsoft.Win32.Registry class</a> to read which application is registered for which file format.</p>\n\n<p>Here are two articles that might be helpful:</p>\n\n<ul>\n<li><a href="http://www.informit.com/articles/article.aspx?p=26957" rel="nofollow noreferrer">Reading and Writing the Registry in .NET</a></li>\n<li><a href="http://www.dotnetspider.com/resources/988-Windows-Registry-using-C.aspx" rel="nofollow noreferrer">Windows Registry Using C#</a></li>\n</ul>\n'}, {'answer_id': 24974, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 4, 'selected': True, 'text': '<p>Sample code:</p>\n\n<pre><code>using System;\nusing Microsoft.Win32;\n\nnamespace GetAssociatedApp\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            const string extPathTemplate = @"HKEY_CLASSES_ROOT\\{0}";\n            const string cmdPathTemplate = @"HKEY_CLASSES_ROOT\\{0}\\shell\\open\\command";\n\n            // 1. Find out document type name for .jpeg files\n            const string ext = ".jpeg";\n\n            var extPath = string.Format(extPathTemplate, ext);\n\n            var docName = Registry.GetValue(extPath, string.Empty, string.Empty) as string;\n            if (!string.IsNullOrEmpty(docName))\n            {\n                // 2. Find out which command is associated with our extension\n                var associatedCmdPath = string.Format(cmdPathTemplate, docName);\n                var associatedCmd = \n                    Registry.GetValue(associatedCmdPath, string.Empty, string.Empty) as string;\n\n                if (!string.IsNullOrEmpty(associatedCmd))\n                {\n                    Console.WriteLine("\\"{0}\\" command is associated with {1} extension", associatedCmd, ext);\n                }\n            }\n        }\n    }\n}\n</code></pre>\n'}, {'answer_id': 33359, 'author': 'Anders', 'author_id': 3501, 'author_profile': 'https://Stackoverflow.com/users/3501', 'pm_score': 3, 'selected': False, 'text': "<p>@aku: Don't forget HKEY_CLASSES_ROOT\\SystemFileAssociations\\</p>\n\n<p>Not sure if they are exposed in .NET, but there are COM interfaces (IQueryAssociations and friends) that deal with this so you don't have to muck around in the registry and hope stuff does not change in the next windows version</p>\n"}, {'answer_id': 917635, 'author': 'Barakando', 'author_id': 104961, 'author_profile': 'https://Stackoverflow.com/users/104961', 'pm_score': 3, 'selected': False, 'text': '<p>Like Anders said - It\'s a good idea to use the IQueryAssociations COM interface.\nHere\'s a <a href="http://www.pinvoke.net/default.aspx/shlwapi/AssocCreate.html" rel="noreferrer">sample from pinvoke.net</a></p>\n'}, {'answer_id': 4174130, 'author': 'user362515', 'author_id': 362515, 'author_profile': 'https://Stackoverflow.com/users/362515', 'pm_score': 1, 'selected': False, 'text': '<p>Also HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\</p>\n\n<p>.<em>EXT</em>\\OpenWithList key for the "Open width..." list (\'a\', \'b\', \'c\', \'d\' etc string values for the choices)</p>\n\n<p>.<em>EXT</em>\\UserChoice key for the "Always use the selected program to open this kind of file" (\'Progid\' string value value)</p>\n\n<p>All values are keys, used the same way as <strong>docName</strong> in the example above.</p>\n'}]
['https://Stackoverflow.com/questions/24954', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2669/']