ProcessShellCommand throws "Access is denied"

0

Due the migration from Win7+VS2015 to Win10+VS2017 we face following issue in our old MFC tool:

from afxwin.h: CWnd* m_pMainWnd; // main window (usually same AfxGetApp()->m_pMainWnd)

CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CIFX_LogViewDoc),
    RUNTIME_CLASS(CMainFrame),       // main SDI frame window
    RUNTIME_CLASS(CIFX_LogViewView));
AddDocTemplate(pDocTemplate);   

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo)) // -> "Access is denied"
    return FALSE;

// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();

return TRUE;

I also tried to call ShowWindow()+UpdateWindow() before parsing the command line as suggested here: https://stackoverflow.com/a/41188727/384556 but it does't work:

Exception thrown at 0x58198F2E (mfc140d.dll) in A.exe: 0xC0000005: Access 
violation reading location 0x00000020. occurred -> in m_pMainWnd->ShowWindow(SW_SHOW);

Any other ideas?

c++
visual-studio
mfc
visual-studio-2017
asked on Stack Overflow Nov 21, 2017 by leon22 • edited Nov 21, 2017 by leon22

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0