This site is no longer active and is available for archival purposes only. Registration and login is disabled.

FreeResource() & UnlockResource()


FreeResource() & UnlockResource()

Postby fzammetti » Jun 19, 2002 @ 8:44pm

...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"
User avatar
fzammetti
pm Insider
 
Posts: 1496
Joined: Jun 4, 2002 @ 6:21pm
Location: Omnytex Technologies


Postby Dave » Jun 19, 2002 @ 10:33pm

Dave
 


Postby Digby » Jun 19, 2002 @ 11:55pm

There is no need for FreeResource. When the module containing the resource is loaded, the resource is loaded into a read-only page(s) of system memory. LoadResource returns a pointer to this area of read-only memory to all who ask for it. Since it's read-only the OS doesn't need to perform a copy on write so only one copy need be in memory at a time. The way you free this bit of memory is to unload the module.

Also disregard that blurb in the docs about using DeleteObject, DestroyCursor, etc. in order to free the resource. That's just wrong. In the case of bitmap resources, GDI only knows about handles to GDI objects and the LoadResource does not return a GDI handle. Passing in the value returned by LoadResource to DeleteObject will fail.

All those Lock/Unlock shenanigans are a hold over from Win16 where you would have to lock global memory before using it and then unlock afterwards so the memory manager could defragment the global heap.
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Postby refractor » Jun 20, 2002 @ 9:09am

User avatar
refractor
pm Insider
 
Posts: 2304
Joined: Feb 5, 2002 @ 1:12pm
Location: Luxembourg


Postby angedelamort » Jun 20, 2002 @ 2:34pm

User avatar
angedelamort
pm Member
 
Posts: 304
Joined: Mar 7, 2002 @ 11:16pm
Location: Montreal, Quebec


Thanks!

Postby fzammetti » Jun 20, 2002 @ 3:33pm

...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"
User avatar
fzammetti
pm Insider
 
Posts: 1496
Joined: Jun 4, 2002 @ 6:21pm
Location: Omnytex Technologies


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum