当初在创建MFC工程的时候没有勾选高级设置中的 支持“ActiveX” 事后如何更改这个设置?

还是我自己查了下MSDN 调用在应用程序对象的 InitInstance 函数中对此函数启用 OLE 控件包容的支持。void AfxEnableControlContainer( );

第1个回答  2014-11-12
1,在资源中增加 字符串资源 IDP_OLE_INIT_FAILED "OLE initialization failed. Make sure that the OLE libraries are the correct version." 同时在Resource.h文件中已经自动增加了该资源的定义了。
2,在stdafx.h文件中增加包含 #include <afxdisp.h>
3,在YourApp.cpp中的InitInstance中增加
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();

在ExitInstance中增加 AfxOleTerm(FALSE);本回答被网友采纳
相似回答