The problem I need to solve is how to use the MFC function ProcessShellCommand()
in the InitInstance()
of a CWinApp
to process a File
I'm updating a desktop application from VC++ to Visual Studio 2017 and encountered the same problem when the user was trying to open a File with a double click from the Explorer. In my case, I just had to add this code:
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox("Could not open the file! \nTry open CS Setup first and then open the file using the menu \"File->Open...\".", MB_ICONERROR);
return FALSE;
}