views:

162

answers:

1

When right-clicking a file in Windows Explorer, the "Open with" menu item displays a list of available applications, based on the file type of the clicked file.

See this picture as an example:

"Open with" context menu in Windows Explorer

Now I want to be able to programmatically read the list of applications for a given file extension/type (e.g. "png") from within a C# .NET 2.0 application.

E.g.

public class FileOpenInfo
{
    public string ApplicationName { get; }
    public string ApplicationPath { get; }

    public static FileOpenInfo[] GetInformation( string extension );
}

Question:

Is it possible to get this list?

Thank you
Uwe

+1  A: 

The list of programs associated with a file extension are stored in the Windows Registry.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts

The Microsoft.Win32 contains the classes to access the registry.
For more information, read more here

Zyphrax
Thank you, I will take a look. I guess that the application probably needs administrative permissions (which it doesn't have) to enumerate the registry.
Uwe Keim
My guess is that enumerating will be possible without elevation. Make sure you use the proper overload of the RegistryKey class to open it read-only.
Zyphrax