The following is a clear document for the allocation of Win32 resources found in a certain browse, and only a few texts are translated. Should
Documents have a great help to prevent resource leakage. Sorry, I have a string on it.
*********************************************************** ********************
Resource Allocation Function Clear Function needs to be cleared manually?
============================================================================================================================================================================================================= ====================
Accelerators loadAccelerators N / A NO
Atoms GlobalAddatom GlobalFreeaTom Yes
Bitmaps createBitMap DeleteObject Yes *
CreateBitMap Indirect 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 YesLoadCursor 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 GetStockOckObject 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 Nogloballock 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%
LoadMenu Indirect DestroyMenu NO%
GetsystemMenu N / A NO
Metafile CreateMetafile deletemetafile Yes
Palette CreatePalette DeleteObject Yes
Pen Createpen deleteObject Yes
CreatepenIndirect DeleteObject Yes
Regions CreatellipticRgn DleteObject Yes
CreatellipticRgn Indirect DeleteObject Yes
CreatePolygonRgn DleteObject Yes
CreatePolyPolygonRgn DleteObject Yes
CreateRectrgn deleteObject Yes
CreateRectrignInderct deleteObject Yes
CreateroundRectRgn deleteObject Yes
Resource AllocResource Freeresource NO
FindResource N / A NO
LoadResource Freeresource No
LockResource UnlockResource No OpenSound Closeesound Yes
String LoadString N / A NO
Thunk MakeProcinstance FreeProcinstance NO
Timer setTimer Killtimer No
Window CreateWindow DestroyWindow No
CreateWindowex DestroyWindow NO
NOTES:
--------
* Bitmap Resources must be detached from the selected DC when released.
% When the menu is lost focus and window no longer association or the application is occupied, the resource must be released.
The @ DC must be associated with the bitmap that must be associated with it (selected) before being released.
# If the character is specified, the bitmap must be released.
& To deleteObject calls will not destroy regular stockObjects (system internal resource)