Board index » Visual Studio » File Associations Revisited
|
TereGardner
|
File Associations Revisited
Visual Studio233
A few weeks back I thought I had figured out how to programmatically change the file association between different versions of my program, but actually I do not see how to do it on Vista, and I am beginning to think it is not possible without getting into the whole Default Programs API. To summarize, on 95/NT/98 the old way of modifying HKCR\<ext>works (except for non-admin on NT). On Me/2000/XP this method typically does not work because the HKCR settings may be overruled by use of the "Open With" facility, which puts its entries in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\Application and/or HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\Progid These two values are treated slightly differently by Me/2000/XP, but it is pretty easy to set these values in code in a way that is consistent with the OpenWith mechanism. In Vista, these two values are replaced by HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\UserChoice\Application and/or HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\UserChoice\Progid but otherwise I thought that it was the same thing. I did wonder, though, why the extra UserChoice key was introduced. Today I found out why. The above two values (in fact the entire UserChoice key) cannot be written to, either in code, or directly in the registry editor (even if you run as administrator). You can only change these values by manually running the Open With mechanism. So it seems to be that it is no longer possible in Vista to change the association in code, unless you get into the Default Programs API (which is Vista-specific). David Wilkinson - |
