在VB6 IDE中工作时卸载COM控件 [英] Unload a COM control when working in VB6 IDE

查看:194
本文介绍了在VB6 IDE中工作时卸载COM控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的日常工作的一部分是维护和扩展传统的VB6应用程序。通用引擎是用C / C ++编写的,VB6使用这些函数来提高性能。



当涉及到异步编程时,C接口是不够的,我们依靠COM控件来触发事件到VB6。



我的问题是,当我在VB6注册控件,VB加载这个控件在内存中,不卸载它,直到我退出VB6 IDE。因为控件被加载了整个时间,我无法重新编译它在VC6,因为DLL文件被锁定。



我发现一个解决方案是不是启用控件在VB中,但使用 CreateObject()与我的控制的全名。问题是,我必须声明我的控件作为一个对象,因为VB6不知道我使用的界面,我没有访问IntelliSense,这是一个痛苦。



任何想法如何告诉VB6卸载控制退出应用程序后?或者直接在IDE中?

解决方案

我确定没有办法强制VB6卸载控件。 p>

这里是我做的...而不是并行运行Visual C和Visual Basic运行VB6 VC:


  1. 加载VC

  2. 打开包含COM对象的项目

  3. 编辑,更改等。

  4. 在VC中,使用适当的命令行参数将输出可执行文件设置为VB6.EXE以加载VB6工作区

  5. 现在只需点击F5即可启动VB6 IDE并加载您的VB6项目

  6. 当您想再次更改COM代码时,请退出VB6.EXE,进行更改,然后再次按F5。只要保存您的工作区,VB6就会记住您打开的窗口和您的所有项目设置。

此方法的优点: / p>


  • 您可以在COM对象中设置断点并使用完整的源代码调试器调试


  • 每当VB6运行时,它总是具有最新版本的COM DLL

Part of my everyday work is maintaining and extending legacy VB6 applications. A common engine is written in C/C++ and VB6 uses these functions in order to improve performance.

When it comes to asynchronous programming, a C interface is not enough and we rely on COM controls to fire events to VB6.

My problem is that when I register the control in VB6, VB loads this control in memory and does not unload it until I quit the VB6 IDE. As the control is loaded the whole time, I am unable to recompile it in VC6, because the DLL file is locked.

A solution I found is not to enable the control in VB but use the CreateObject() with the full name of my control. The problem then is that I must declare my control as an Object because VB6 knows nothing of the interface I am using and I do not have access to IntelliSense, which is a pain.

Any idea how I can tell VB6 to unload controls after quitting the application? Or directly in the IDE?

解决方案

I'm pretty sure there's no good way to force VB6 to unload the control.

Here's what I do... instead of running Visual C and Visual Basic side-by-side, run VB6 under VC :

  1. Load up VC
  2. Open the project containing your COM objects
  3. Edit, change, etc.
  4. In VC, set the Output Executable to be VB6.EXE with appropriate command-line arguments to load the VB6 workspace
  5. Now just hit F5 to launch the VB6 IDE and load your VB6 project
  6. When you want to change the COM code again, exit VB6.EXE, make your changes, and hit F5 again. As long as you save your workspace VB6 will remember what windows you had open and all your project settings.

Advantages of this method:

  • You can set breakpoints in the COM object and debug it using a full source debugger
  • You can happily debug in C and VB at the same time
  • Whenever VB6 is running it always has the latest version of the COM DLLs

这篇关于在VB6 IDE中工作时卸载COM控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆