I have been trying to find a way to change the default file association for a specific file extension in windows 7. I have an app that is used to view .tif files that I want to prompt th user if its not the default viewer for that file type. If they choose to make it the default, I want to override the current default viewer. This works fine if there are no other viewers installed on the system. When there is another viewer that has been selected by the user, I cannot change the registry key that controls that here:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\UserChoice
I have scoured the web trying to find someone that has done this, but nobody seems to have any answers. When I try to update the "Progid" value within this key, I get a "Cannot write to the registry key" or "Requested registry access is not allowed" errors. The code is simple enough:
var path = @"Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\UserChoice";
var key = Registry.CurrentUser.OpenSubKey(path, true);
key.SetValue("Progid", "myprogid...");
Is there some special protection on this key that prevents it from being programmatically edited?