我是否需要DeleteObject时,使用处置一个HBITMAP *的[ComImportAttribute()? [英] Do I need to DeleteObject to dispose of an HBITMAP* when using [ComImportAttribute()]?

查看:188
本文介绍了我是否需要DeleteObject时,使用处置一个HBITMAP *的[ComImportAttribute()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

::的getImage

这是调用者释放该检索的资源的责任   通过 DeleteObject 时它不再需要。

It is the responsibility of the caller to free this retrieved resource through DeleteObject when it is no longer needed.

我的问题是:

我使用了的IntPtr IShellItemImageFactory.GetImage 调用其中 IShellItemImageFactory 饰有 [ComImportAttribute()] 。我是否还需要调用 DeleteObject ,或将那作祟当CLR(?)会尝试删除它作为厂的一部分

I'm using the IntPtr in an IShellItemImageFactory.GetImage call where the IShellItemImageFactory is decorated with [ComImportAttribute()]. Do I still need to call DeleteObject, or will that cause trouble when the CLR(?) will try deleting it as part of the Factory?

推荐答案

CLR将永远自动释放一个IntPtr。它不可能知道具体的功能需要被调用来释放指针什么。这完全取决于你的PInvoke DeleteObject()。

The CLR will never automatically release an IntPtr. It cannot possibly know what specific function needs to be called to release the pointer. It is entirely up to you to pinvoke DeleteObject().

这篇关于我是否需要DeleteObject时,使用处置一个HBITMAP *的[ComImportAttribute()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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