Programmatically opening the 'Default Programs' window
Windows Vista comes with a new feature called Default Programs (which replaces the Set Program Access and Default and File Types feature from Windows XP). This cool new feature provides a user friendly way of changing program defaults, such as file and protocol associations and AutoPlay settings.
The recommendations going forward is that on Windows Vista or higher, applications use the new UI to allow users to customize file associations for an application instead of providing their own. This provides a consistent look and feel for every application and provides a single place for users to change these settings.
Unfortunately, to programmatically interact with this feature is not as straight forward as you might think from managed code if you've never done COM interop. The docs for these APIs leave a lot to be desired (why common return values from COM methods aren't called out on MSDN - I don't know) and there are, at the time of writing, no samples for calling them.
To save you most of the trouble, I've gone ahead and written a small wrapper around the IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI method, which displays the file association window for a particular application.
To use this method, simply take a reference to the below attached project and write something like:
static void Main()
{
System.Windows.DefaultApplications.ShowAssociationsWindow("Internet Explorer");
}
The above example, will open the Set associations for a program window for Internet Explorer:
The name of the application to pass to DefaultApplications.ShowAssociationsWindow comes from one of the registry values under HKEY_LOCAL_MACHINE\Software\RegisteredApplications. Information on this key can be found at Registering an Application for Use with Default Programs.
For now, download the wrapper (System.Windows.DefaultApplications.zip) and tell me what you think.
For additional information on how to make your application play nicely with Default Programs, see http://msdn.microsoft.com/en-us/library/bb776873.aspx