ProcessShellCommand抛出“访问被拒绝”

时间:2017-11-21 09:16:53

标签: c++ visual-studio mfc visual-studio-2017

由于从Win7 + VS2015迁移到Win10 + VS2017,我们在旧的MFC工具中面临以下问题:

  来自afxwin.h的

:CWnd * m_pMainWnd; //主窗口(通常是相同的   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;

我还尝试在解析命令行之前调用ShowWindow()+ UpdateWindow(),如下所示:https://stackoverflow.com/a/41188727/384556但它不起作用:

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

还有其他想法吗?

0 个答案:

没有答案