資源 分配函式 清除函式 需要手動清除
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
dialogbox 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
gdistockobj 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
createwindowex destroywindow no
* 位圖資源在釋放的時候必須從選中它的dc中脫離;
% 當選單失去焦點和視窗不再關聯或者應用程式結束的時候占用資源必須被放;
@ dc被釋放前必須和它關聯(選中)的點陣圖取消聯絡;
# 如果脫字元指定了點陣圖,位圖必須被釋放;
& 對deleteobject的呼叫不會銷毀常規的stockobject(系統內定資源)。
記憶體分配函式
2.c中提供堆區供給開發者分配記憶體空間,動態記憶體分配函式malloc,calloc,realloc 1 malloc函式的使用,原型為void malloc int length 引數為分配記憶體空間的大小 將記憶體分配4個位元組給乙個int型指標 返回值為任何指標 考慮到不同平台,可以使用si...
記憶體分配函式
1 malloc 函式 void malloc unsigned int size 在記憶體的動態分配區域中分配乙個長度為size的連續空間,如果分配成功,則返回所分配記憶體空間的首位址,否則返回null,申請的記憶體不會進行初始化。2 calloc 函式 void calloc unsigned ...
手撕虛函式,虛函式呼叫虛函式
乙個類的記憶體分布,虛函式表指標,普通成員變數,sizeof a 為乙個虛表指標 32位是4位元組 普通成員變數 靜態什麼的都不是 虛函式本身也是函式,相當於乙個指標,虛函式表裡面含有虛函式,相當於乙個二級指標,虛函式表指標指向虛函式表,相當於乙個 指標,所有可以通過乙個 指標直接訪問某個虛函式。見...