Below is a clear document for the allocation of Win32 resources found in a browser, which simply translates a few texts. The
This document is of great help to prevent resource leaks.
========================================================== ==========================================================
Does the resource allocation function need to be cleared manually?
========================================================== ==========================================================
Accelerators loadaccelerators N/A No
Atoms globaladdatom globalfreeatom Yes
Bitmaps createbitmap deleteobject Yes *
Createbitmapindirect deleteobject Yes *
Createcompatiblebitmap deleteobject Yes *
Createdibitmap deleteobject Yes *
Creatediscardablebitmap deleteobject Yes *
Loadbitmap deleteobject Yes *
Brushes createbrushindirect deleteobject Yes
Createdibpatternbrush deleteobject Yes
Createhatchbrush deleteobject Yes
Createpatternbrush deleteobject Yes
Createsolidbrush deleteobject Yes
Carets createcaret destroycaret no #
Clipboard openclipboard closeclipboard Yes
Comms ports opencomm closecomm Yes
Cursor createcursor destroycursor Yes
Loadcursor N/A No
DC createdc deletedc Yes
Createcompatibledc deletedc Yes @
Getdc releasedc Yes
Getwindowdc releasedc Yes
Beginpaint endpaint Yes
Dialog Box createdialog destroywindow No
Createdialogindirect destroywindow No
Createdialogindirectparam destroywindow No
Createdialogparam destroywindow No
File openfile _ lclose No
fonts createfont deleteobject Yes
createfontindirect deleteobject Yes
addfontresource removefontresource Yes
GDI stock OBJ getstockobject N/A No &
Hook setwindowshook unhookwindowshook Yes
IC createic deletedc Yes
Icon createicon destroyicon Yes
Loadicon N/A No
Library loadlibrary freelibrary Yes
Memory allocdstocsalias freeselector Yes
Allocselector freeselector Yes
Globalalloc globalfree No
Globaldosalloc globaldosfr No
Globalfix globalunfix No
Globallock globalunlock No
Globalpagelock globalpageunlock No
Globalrealloc globalfree No
Globalwire globalunwire No
Localalloc localfree No
Locallock localunlock No
Localrealloc localfree No
Menu createmenu destroymenu no %
Createpopupmenu destroymenu no %
Loadmenu destroymenu no %
Loadmenuindirect destroymenu no %
Getsystemmenu N/A No
Metafile createmetafile deletemetafile Yes
Palette createpalette deleteobject Yes
Pen createpen deleteobject Yes
Createpenindirect deleteobject Yes
Regions createellipticrgn deleteobject Yes
Createellipticrgnindirect deleteobject Yes
Createpolygonrgn deleteobject Yes
Createpolypolygonrgn deleteobject Yes
Createrectrgn deleteobject Yes
Createrectrgnindirect deleteobject Yes
Createroundrectrgn deleteobject Yes
Resource allocresource freeresource No
Findresource N/A No
Loadresource freeresource No
Lockresource unlockresource No
Sound opensound closesound Yes
String loadstring N/A No
Thunk makeprocinstance freeprocinstance No
Timer settimer killtimer No
Window createwindow destroywindow No
Createmediawex destroywindow No
========================================================== ==========================================================
Notes:
* When a bitmap resource is released, it must be removed from the selected DC.
% When the menu loses focus and the window is no longer associated or appliedProgramThe occupied resources must be released at the end.
@ DC must be associated with (selected) bitmap to cancel contact before it is released
# The bitmap must be released if the bitmap is specified
& Call deleteobject does not destroy General stockobject (system-defined resources)
========================================================== ==========================================================