I’m trying to open the editor associated with ‘txt’ files – here’s the rub though, my file doesn’t actually have the txt extension, so I can’t just ShellExecute it, I have to find the associated program by hand.
To do this, I’ve been trying to use the IApplicationAssociationRegistration::QueryCurrentDefault COM method from Shell, but it returns a ProgId, which is less than useless to me. How can I map this to an EXE? I’m using C#, but it doesn’t seem relevant.
Edit: The approach linked below where you directly access the Registry doesn’t work in all cases anymore. The correct way is above, but I need the next step – how do I take the returned ProgId and get the associated program?
To execute one file as if it were another type of file, call
ShellExecuteand set the thelpClassmember of theSHELLEXECUTEINFOstructure to the progid you wish the file were.It is important to do it this way, because the default handler for text files is not necessarily a program with a command line. It might be a DDE server or a drop target or a context menu handler or a delegated execution handler.