windows - 如果我使用 LoadIconWithScaleDown 实现,是否需要调用 DestroyIcon?

标签 windows winapi

我正在使用 LoadIconWithScaleDown() 在我的应用程序中创建图标.我也退回到CreateIconFromResourceEx()如果首选功能不可用。

DestroyIcon() 的文档状态:

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. Do not use this function to destroy a shared icon. A shared icon is valid as long as the module from which it was loaded remains in memory. The following functions obtain a shared icon.

  • LoadIcon
  • LoadImage (if you use the LR_SHARED flag)
  • CopyImage (if you use the LR_COPYRETURNORG flag and the hImage parameter is a shared icon)
  • CreateIconFromResource
  • CreateIconFromResourceEx (if you use the LR_SHARED flag)

注意:我没有将 LR_SHARED 传递给 CreateIconFromResourceEx();也许我应该。

我想知道的是,用LoadIconWithScaleDown()制作的图标需要调用DestroyIcon()吗?

最佳答案

我会说是的,因为根据文档,您要取回的 HICON 似乎并未共享。 Windows 显然不希望你销毁共享句柄的图标,但这里不是这种情况,如果你回退到另一个采用 LR_SHARED 但你没有传递标志的函数,那么这意味着你的进程拥有该图标handle,用完后应该销毁它。

关于windows - 如果我使用 LoadIconWithScaleDown 实现,是否需要调用 DestroyIcon?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5276390/

相关文章:

C - 无法绑定(bind)服务器套接字

c++ - 使用 MinGW 编译的 libx264 - 缺少 __umoddi3、__udivdi3、_fseeko64 和 __chkstk_ms

c - 将结构指针发送到多个对话框实例的 WndProc

c++ - 将字符串作为字节序列写入文件

windows - 在 Windows 上启动 Redis 失败

asp.net - HTTP 错误 404.17 - 未找到 - .NET - IIS 10

c - 在 Win32 中等待串口传输完成

delphi - 为什么调用 IShellFolder._Release 时会出现错误?

c++ - 列出特定用户的进程

python - 在python中打开单独驱动器上的文件