用 LoadResource 装入的资源如何释放?

向明工作室 2007-03-13 12:06:34
用 LoadResource 装入的资源如何释放?
FreeResource 已被作废,用delete 释放有时没问题,有时却有问题。
...全文
745 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
向明工作室 2007-03-14
  • 打赏
  • 举报
回复
谢了!
w_anthony 2007-03-13
  • 打赏
  • 举报
回复
msdn上说,现在的Windows系统(大概是95以上)提供的LoadResource这个API,只是取得一个已经载入的资源的内存起始地址而已,并不会分配额外的内存资源。当使用FreeLibrary的时候,才会真正将所有资源释放掉。FreeResource对现在的系统来说,实际上是不做任何处理的。

但如果你要兼容Windows3.x,可以用LoadResource和FreeResource配对使用,反正这样写的话,对哪个系统都没错。
菜牛 2007-03-13
  • 打赏
  • 举报
回复
Destroy...()
syy64 2007-03-13
  • 打赏
  • 举报
回复
FreeResource
The FreeResource function is obsolete. It is provided to simplify porting of 16-bit Win32-based applications. It is not necessary for Win32-based applications to free resources loaded by using the LoadResource function. The resource obtained by LoadResource is automatically freed when the module is was loaded from is unloaded. However, to save memory and decrease the size of your process's working set, you should release the memory associated with accelerator tables, bitmaps, cursors, icons, and menus by calling the functions in the following table.

Resource Release function
Accelerator table DestroyAcceleratorTable
Bitmap DeleteObject
Cursor DestroyCursor
Icon DestroyIcon
Menu DestroyMenu


See Also
Resources Overview, Resource Functions

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧