CShellManager初始化失败

时间:2020-07-24 11:27:18

标签: c++ mfc

嗨,

我的配置是:

  • Windows 10 Visual Studio 2019
  • 我用过MFC和c ++。

我创建了一个CDialogEx,在其中使用CMFCShellTreeCtrl和CMFCShellListCtrl。

我已经包含了头文件:afxwinappex.h和afxshellmanager.h

我的应用程序开始于

BOOL CtestsApp::InitInstance()
{
...
 CWinAppEx *pApp;
 pApp = DYNAMIC_DOWNCAST(CWinAppEx, AfxGetApp);
 pApp->InitShellManager();
...
}

当我通过InitShellManager()函数进行跟踪时,出现违规情况,见下文

BOOL CWinAppEx::InitShellManager()
{
    /* afxShellManager is NULL */
    if (afxShellManager != NULL) 
    {
        return (TRUE);
    }

    afxShellManager = new CShellManager;
    m_bShellManagerAutocreated = TRUE; 
    /* ==> Problem violation write */
    return (TRUE);
}

为什么?

1 个答案:

答案 0 :(得分:0)

感谢您的回复。我将CWinApp更改为CWinAppEx,并调用了InitShellManager();。

一切都很好