VB6 中的 AddRef()
是否可以从 Visual Basic 6 中的接口 IUnknown 调用方法 AddRef() 或实现一些 hack 来增加对象引用计数器?
is it possible to call method AddRef() from interface IUnknown in visual basic 6 or implement some hack to increment object reference counter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试人为地增加引用计数器(在 VB6 完成的自动引用计数之外),那么您可以执行以下操作:
您可能还需要实现相反的操作才能释放,否则您将得到一个各种内存泄漏。
If you are trying to artificially increment the refrence counter (outside of the automatic reference counting that is done by VB6) then you can do the following:
You'll probably need to implement the reverse of this as well to release or you will get a memory leak of sorts.
我相当确定 VB6 不支持直接访问 IUnknown 方法。但解决方法很简单。将此声明添加到模块中:
然后使用简单的赋值来调用 AddRef() 。
相反,使用 Release() 来调用
这是正常的 VB6 内存管理工作。
I'm fairly sure that VB6 doesn't support directly accessing the IUnknown methods. But the workaround is simple. Add this declaration to a Module:
And then get AddRef() to get called with a simple assignment
Reversely, get Release() to get called with
This is normal VB6 memory management at work.