这次还有一个简单的问题:我处理 UI 内容的 DLL 有一个 uninit()
function that should be called before the program terminates that frees all resources (注销窗口类、删除私有(private)堆等)。卸载使用 LoadIcon
/Cursor(NULL, IDI) 加载的
/IDI_APPLICATION
、IDC_ARROW
和其他系统图标和光标所需的调用是什么IDC_WHATEVER)
?我从 MSDN 了解到的最接近的是不应在这些图标上调用 DeleteObject()
;那么没有这样的功能吗?谢谢。
最佳答案
您不会卸载系统定义的图标或光标。 documentation for 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)
上面清楚地表明,使用 LoadIcon() 获得的图标不应被破坏。 documentation for DestroyCursor中也有同样的说法。 :
Destroys a cursor and frees any memory the cursor occupied. Do not use this function to destroy a shared cursor.
关于c - 如何释放标准图标和光标(使用 LoadIcon/Cursor(NULL, IDI/IDC_WHATEVER) 加载的图标和光标)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30603077/