with SHOpenWithDialog
how to open "how do you want to open this file" dialog no matter if a standard application suitable for a file type?
I want to open the following dialog with or without a standard application suitable for a file type.
I can use ShellExecute to open this dialog. But if there is an default application for that file, for example .txt file.
It will open by notepad directly instead of open the "how do you want to open this file" dialog
(I am using visual studio c++)
1 additional answer
Sort by: Most helpful
-
Rodney McManamy 1 Reputation point
2022-04-08T17:39:11.81+00:00 If you are trying to open the default program FROM a 32 bit program in 64 bit Windows the ShellExecute and ShellExecuteEX may display the "How do you want to open this file?" dialog box each time. This is due to the way that the default program registered itself in Windows I think.
I was able to reproduce this error on Windows 11 64 bit fresh install where the Photos is set to the Default Program for .jpg files.
In my case I found that if I use the ShellExecuteExW function and pass the extension in to the .lpClass of SHELLEXECUTEINFOW Type that it works.
It should also work with the ShellExecuteExA function
1.) Make sure it's not an exe, reg, or bat file or a url you are trying to open. It has to be a document type of file.
2.) Use the .lpClass to pass the extension like .lpClass = ".jpg"
3.) Add the SEE_MASK_CLASSNAME As Long = &H1 to the .fMask parameter you are passing in like .fMask = YourMaskValue Or SEE_MASK_CLASSNAMEThe reason I think this works is it bypasses any redirection and reads directly from the HKEY_CLASSES_ROOT.jpg