Setup Query for Gary: FreeResource

Max Bowsher
Sat Aug 2 11:10:00 GMT 2003

Gary R. Van Sickle wrote:
>> Robert Collins wrote:
>>> On Sat, 2003-08-02 at 05:16, Max Bowsher wrote:
>>>> According to the MS docs, FreeResource is an obsolete 16-bit
>> compatibility
>>>> function. Do we really want/need to use it?
>>> MS  recommend using DeleteIcon etc rather than it for new code - and
>>> yes, its nice to free resources we've used :}.
> Trouble is, its a dialog template that I'm loading, and there's no
> "DestroyDialog()" or something to otherwise do the job.
>> Well, yes, obviously, its nice, but will FreeResource do it? In the
>> docs I was looking at, FreeResource wasn't even documented - just
>> in a list of obsolete functions. It is documented in MSDN - as being the
>> complement to LoadResource.
> Yep, thusly:
> "The FreeResource function is obsolete and is only supported for backward
> compatibility with 16-bit Microsoft® Windows®."
> Sheesh, I must be getting old!
>> We can only guess how LockResource fits into
>> this picture.
> No need to guess, my good man!:
> "The return type of LoadResource is HGLOBAL for backward compatibility,
> because the function returns a handle to a global memory block. Do not
> this handle to the GlobalLock or GlobalFree function. To obtain a pointer
> the resource data, call the LockResource function."
> "The pointer returned by LockResource is valid until the module containing
> resource is unloaded. It is not necessary to unlock resources because the
> system automatically deletes them when the process that created them
> terminates."
> As I assume is clear, the only reason I'm dinking with these templates at
> is to get the original size of the various pages as specified in res.rc.
> think the FreeResource() should be left in unless it causes problems, or
> until a better way can be found to get the needed info, and I did do
> considerable research to those ends and came up empty.

OK, I just wanted this to be discussed.

Now it has been, I'm happy.


More information about the Cygwin-apps mailing list