Unhandled exception in XXX.exe(MFCO42D.dll)0xC00000005:Access Violation

来源:互联网 发布:正定矩阵因子分解模型 编辑:程序博客网 时间:2024/05/29 10:50

在引用shockwave flash object 控件时,出现问题Unhandled exception in XXX.exe(MFCO42D.dll)0xC00000005:Access Violation的烦人问题。

代码如下: CShockwaveFlash *m_flash = new CShockwaveFlash; //FLASH处理类

if(m_flash != NULL)

{ m_flash->Create(_T("Flash"), WS_CHILD|WS_VISIBLE, CRect(100,100,700,800),pDC->GetWindow(),2500);

m_flash->LoadMovie(0,"e://wellBedMonitor.swf");

m_flash->Play();

}

错误出在Create函数中,这种问题一般是内存非法访问,看看那里指针操作有问题,没有初始化,或是引用无效的指针等等。

跟踪进去发现真正问题所在:

AfxEnableControlContainer has not been called yet.

You should call it in your app 's InitInstance function.

解决办法:在app::InitInstance()中加入AfxEnableControlContainer()

 

AfxEnableControlContainer()函数是允许应用程序作为控件容器来使用,也就是说你可以在这个应用程序中使用ocx之类的控件。使用 Visual c + + 4.0 版就可以构建 OLE 控件容器。这些容器必须在其 CWinApp::InitInstance() 调用 AfxEnableControlContainer()。

原创粉丝点击