1

我在应用程序中实现并实例化了ActiveX控件。VB6MFC42

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

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

在某些ActiveX情况下,我们有虚拟代码/数据以允许ActiveX在 Internet Explorer 中执行,加载速度更快,但并非所有人都ActiveX拥有它。

我期望当我单击树视图中的不同项目时,前一个项目ActiveX被卸载,我可以用新版本覆盖它。

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

我在互联网上搜索并找到了两篇 文章ActiveX,他们都建议清理的正确方法是:

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

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

编辑:
或者,对于 VC++ 6(使用 MFC42),而不是Noseratio他的回答CoFreeUnusedLibrariesEx中提到的;我可以使用which 将立即用于单线程公寓 (STA)。CoFreeUnusedLibraries

4

1 回答 1

1

如果 COM 引用计数在您的应用程序中正常工作,您可以尝试使用CoFreeUnusedLibrariesEx.

于 2013-09-19T15:15:16.430 回答