Fix broken Open dialog when launching Dn by opening a file #76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On Windows Vista and up,
RegOverridePredefKey
is necessary for Dn'sRegisterShellFileTypes()
to create .0cc file associations without running as admin. Unfortunately that function also screws with the program's view of the registry. When opening a file from the command line, Dn later runsProcessShellCommand
, which indirectly callsSHGetFileInfo
andSHParseDisplayName
, which queries the registry. WithRegOverridePredefKey
in place, these registry queries load and cache incorrect data, causing file dialogs to see incorrect special folders (like the home directory being called "UsersFiles", and "This PC" disappearing from the sidebar, and sometimes the "Downloads" folder being unclickable).This commit fixes the bug by replacing
RegOverridePredefKey()
withAfxSetPerUserRegistration(TRUE)
(discovered in a 2007 forum post and having literally 9 Google results). This function only affects MFCRegisterShellFileTypes()
and doesn't break special folders. Just to be safe, runAfxSetPerUserRegistration(FALSE)
before callingProcessShellCommand
afterwards. It's safe to omit this call (the bug is still fixed), but I prefer avoiding persistent changes to global state.I tested that .0cc file associations were being created properly using a clean non-admin user account. A build of Dn-FT with
RegOverridePredefKey()
removed was unable to create a .0cc file association. Replacing it withAfxSetPerUserRegistration(TRUE)
fixed the ability to create per-user file associations. However both programs can update the .0cc file association on a user account which already has a per-user .0cc file type/association.Fixes #74.