资源 | 分配函数 | 清除函数 | 是否要手动清除 |
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 |
Cursor | CreateCursor | DestroyCursor | Yes |
LoadCursor | N/A | No | |
DC | CreateDC | DeleteDC | Yes |
CreateCompatibleDC | DeleteDC | Yes | |
GetDC | ReleaseDC | Yes | |
GetWindowDC | ReleaseDC | Yes | |
BeginPaint | EndPaint | Yes | |
Clipboard | OpenClipboard | CloseClipboard | Yes |
Comms Ports | OpenComm | CloseComm | Yes |
Timer | SetTimer | KillTimer | No |
Pen | CreatePen | DeleteObject | Yes |
CreatePenIndirect | DeleteObject | Yes | |
Icon | CreateIcon | DestroyIcon | Yes |
LoadIcon | N/A | No | |
Fonts | CreateFont | DeleteObject | Yes |
CreateFontIndirect | DeleteObject | Yes | |
AddFontResource | RemoveFontResource | Yes | |
DialogBox | CreateDialog | DestroyWindow | No |
CreateDialogIndirect | DestroyWindow | No | |
CreateDialogIndirectParam | DestroyWindow | No | |
CreateDialogParam | DestroyWindow | No | |
File | OpenFile | _lclose | No |
GDIStockObj | GetStockObject | N/A | No |
Hook | SetWindowsHook | UnhookWindowsHook | Yes |
IC | CreateIC | DeleteDC | Yes |
Library | LoadLibrary | FreeLibrary | Yes |
MetaFile | CreateMetaFile | DeleteMetaFile | Yes |
Palette | CreatePalette | DeleteObject | Yes |
Sound | OpenSound | CloseSound | Yes |
String | LoadString | N/A | No |
Thunk | MakeProcInstance | FreeProcInstance | No |
Window | CreateWindow | DestroyWindow | No |
CreateWindowEx | DestroyWindow | No | |
Resource | AllocResource | FreeResource | No |
FindResource | N/A | No | |
LoadResource | FreeResource | No | |
LockResource | UnlockResource | No | |
Menu | CreateMenu | DestroyMenu | No |
CreatePopupMenu | DestroyMenu | No | |
LoadMenu | DestroyMenu | No | |
LoadMenuIndirect | DestroyMenu | No | |
GetSystemMenu | N/A | No | |
Regions | CreateEllipticRgn | DeleteObject | Yes |
CreateEllipticRgnIndirect | DeleteObject | Yes | |
CreatePolygonRgn | DeleteObject | Yes | |
CreatePolyPolygonRgn | DeleteObject | Yes | |
CreateRectRgn | DeleteObject | Yes | |
CreateRectRgnIndirect | DeleteObject | Yes | |
CreateRoundRectRgn | DeleteObject | 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 |
1、位图资源在释放的时候必须从选中它的DC中脱离。
2、当菜单失去焦点和窗口不再关联或者应用程序结束的时候占用资源必须被释放。
3、DC被释放前必须和它关联(选中)的位图取消联系
4、如果脱字符指定了位图,位图必须被释放
5、对DeleteObject的调用不会销毁常规的StockObject(系统内定资源)