I am trying to find a way to change the default file association for a file extension in Windows 7. I have an application that is used to view .tif files that I want to request from a user if this is not the default viewer for this file type. If they want to do this by default, I want to override the current default viewer. This works great if on a system. When there is another viewer that has been selected by the user, I cannot change the registry key that controls here:
HKCU \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ FileExts \ .tif \ UserChoice
I looked at the webpage trying to find someone who did this, but no one seems to have the answers. When I try to update the "Progid" value in this, I get the message "Cannot write to the registry key" or "Requested registry access is not allowed." The code is quite simple:
var path = @"Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\UserChoice"; var key = Registry.CurrentUser.OpenSubKey(path, true); key.SetValue("Progid", "myprogid...");
Is there any special protection on this key that prevents it from being programmatically edited?
Jason
source share