我们应该删除共享图标的 hbmColor 和 hbmMask 吗?

Should we delete hbmColor & hbmMask for a shared icon?

我有一个来自以下代码段的共享图标 HICON

::SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 500, &icon)

然后我检索了它的ICONINFO并复制了hbmColorhbmMask。正如我在 other snippets 中注意到的那样,人们随后调用 ::DeleteObject() 来销毁 hbmColorhbmMask

这对共享图标也有效吗?

MSDN 中所述,我们不应该在共享图标上调用 DestroyIcon,这听起来我们不应该在共享图标的 hbmColor 上调用 DestroyObject & hbmMask 要么。

It is only necessary to call DestroyIcon for icons and cursors created with the following functions: CreateIconFromResourceEx (if called without the LR_SHARED flag), CreateIconIndirect, and CopyIcon.

GetIconInfo 的文档说:

GetIconInfo creates bitmaps for the hbmMask and hbmColor members of ICONINFO. The calling application must manage these bitmaps and delete them when they are no longer necessary.

共享图标同样如此。完成位图后,您必须将其删除。