Search code examples
c++windowsregistryfile-extensionfile-type

How do i open the default application using DelegateExecute?


I want to open a jpg file using the default application the user has set in his/her computer.

The prog id for jpg file from :

Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\UserChoice

is "AppX43hnxtbyyps62jhe9sqpdzxn1790zetc". When i check the shell command for the same from :

Computer\HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\open\command

I get DelegateExecute value of {4ED3A719-CEA8-4BD9-910D-E252F997AFC2}. How can i retrieve a shell command for this application?


Solution

  • To open a file in the users default program, use ShellExecute. Use ShellExecuteEx if you want to force a specific ProgId.

    You are not supposed to read the registry yourself. DelegateExecute is one of 5(ish) ways file type commands can be registered (others include ShellEx extension, DDE and DropHandler).

    If you still want to do this yourself, convert the string to a GUID and use that as the CLSID when you create a COM instance of IExecuteCommand. You basically have to implement the other side of this.