Fix broken Open dialog when launching Dn by opening a file#76
Merged
Gumball2415 merged 1 commit intodevfrom Aug 3, 2021
Merged
Fix broken Open dialog when launching Dn by opening a file#76Gumball2415 merged 1 commit intodevfrom
Gumball2415 merged 1 commit intodevfrom
Conversation
RegOverridePredefKey is necessary to create .0cc file associations on new user accounts, but screws with the program's view of the registry. When opening a file from the command line, Dn later runs ProcessShellCommand, which indirectly calls SHGetFileInfo and SHParseDisplayName, which queries the registry. With RegOverridePredefKey in place, these registry queries load and cache incorrect data, causing file dialogs to see incorrect special folders. This commit fixes the bug by replacing RegOverridePredefKey() with AfxSetPerUserRegistration(TRUE) (discovered in a 2007 forum post at https://social.msdn.microsoft.com/Forums/vstudio/en-US/1f90d106-6cc2-4fd3-a31d-13e742386b5c/calling-cwinappregistershellfiletypes-in-vista?forum=vcgeneral and having literally 9 Google results), which only affects MFC RegisterShellFileTypes(). Just to be safe, run AfxSetPerUserRegistration(FALSE) before calling ProcessShellCommand afterwards. It's safe to omit this call (the bug is still fixed), but I prefer avoiding persistent changes to global state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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,
RegOverridePredefKeyis 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 callsSHGetFileInfoandSHParseDisplayName, which queries the registry. WithRegOverridePredefKeyin 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 callingProcessShellCommandafterwards. 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.