gpt4 book ai didi

c++ - 如何在不终止主应用程序的情况下卸载 ActiveX 的 ocx 以允许覆盖 ocx?

转载 作者:太空宇宙 更新时间:2023-11-04 11:49:38 28 4
gpt4 key购买 nike

我在 VB6 中实现了 ActiveX 控件,并在 MFC42 应用程序中进行了实例化。

I have a tree view structure on the left panel of the application and when different items in the tree are selected, different ActiveX are loaded accordingly on the right panel to display the details of the selected item .

每当我想修改 ActiveXVB 代码时,我都需要重新启动应用程序。这极大地打断了开发流程,因为应用程序启动非常缓慢。

在某些 ActiveX 中,我们有虚拟代码/数据以允许 ActiveX 在 Internet Explorer 中执行,这加载速度更快,但不是我们所有的 ActiveX 有它。

我希望当我在 TreeView 中单击不同的项目时,以前的 ActiveX 被卸载,我可以用新版本覆盖它。

如果 ActiveX 从未被实例化/显示,我可以在应用程序仍在运行时替换 ocx

我在网上搜索了一下,发现two articlesActiveX 上,他们都建议正确的清理方法是:

m_pControl = new CWnd;
m_pControl->CreateControl(strControlProgid,
"",
WS_VISIBLE,
rc,
this,
5000,
NULL,
FALSE,
NULL);
// ...
m_pControl->DestroyWindow();
delete m_pControl;

我们已经使用此方法销毁了 ActiveX,但我仍然需要退出应用程序以覆盖 ocx

编辑:
或者,对于 VC++ 6(带有 MFC42),而不是 Noseratio 提到的 CoFreeUnusedLibrariesExhis answer ;我可以使用 CoFreeUnusedLibraries,它将在单线程公寓 (STA) 中无延迟地工作。

最佳答案

如果 COM 引用计数在您的应用程序中正常工作,您可以尝试使用 CoFreeUnusedLibrariesEx 强制卸载不再使用的 ActiveX DLL。

关于c++ - 如何在不终止主应用程序的情况下卸载 ActiveX 的 ocx 以允许覆盖 ocx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18890695/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com