In FreeResource function - Microsoft Docs:
[This function is obsolete and is only supported for backward compatibility with 16-bit Windows. For 32-bit Windows applications, it is not necessary to free the resources loaded using LoadResource. If used on 32 or 64-bit Windows systems, this function will return FALSE.]
Why is that? Is it because that the memory is large?
The specialized resource-specific functions like LoadBitmap() "post-process" the actual resource into a usable GDI object, which consumes both additional memory and a slot in the system-wide GDI table (limited to 64K handles). Because of that, it is necessary to call DeleteObject() once done with the HBITMAP in order to release the associated resources.
Unlike LoadBitmap() (and unlike 16-bit Windows), LoadResource() does not allocate any additional resources in Win32, but rather "points" to the resource in the memory-mapped image of the already loaded module. Therefore, there is nothing for FreeResource() to clean up in Win32.
Quoting from Raymond Chen's What's the difference between FreeResource and, say, DestroyAcceleratorTable:
In 16-bit Windows, loading a resource entailed allocating a chunk of memory, then filling that memory block from the disk image. In Win32, resources are mapped into the address space as part of the image; there is no memory allocation and no explicit loading.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With