VC資源分配 釋放表

2021-07-23 16:47:53 字數 4079 閱讀 2521

資源

分配函式

清除函式

需要手動清除

accelerators

loadaccelerators

n/a no

atoms

globaladdatom

globalfreeatom

yesbitmaps

createbitmap

deleteobject

yes*

createbitmapindirect

deleteobject

yes*

createcompatiblebitmap

deleteobject

yes*

createdibitmap

deleteobject

yes*

creatediscardablebitmap

deleteobject

yes*

loadbitmap

deleteobject

yesbrushes

createbrushindirect

deleteobject

yescreatedibpatternbrush

deleteobject

yescreatehatchbrush

deleteobject

yescreatepatternbrush

deleteobject

yescreatesolidbrush

deleteobject

yescarets

createcaret

destroycaret

no#clipboard

openclipboard

closeclipboard

yescomms

ports

opencomm

closecomm

yescursor

createcursor

destroycursor

yesloadcursor

n/a no

dccreatedc

deletedc

yescreatecompatibledc

deletedc

yes@

getdc

releasedc

yesgetwindowdc

releasedc

yesbeginpaint

endpaint

yesdialogbox

createdialog

destroywindow no

createdialogindirect

destroywindow no

createdialogindirectparam

destroywindow no

createdialogparam

destroywindow no

file

openfile

_lclose no

fonts

createfont

deleteobject

yescreatefontindirect

deleteobject

yesaddfontresource

removefontresource

yesgdistockobj

getstockobject

n/ano&

hook

setwindowshook

unhookwindowshook

yes ic

createic

deletedc

yesicon

createicon

destroyicon

yesloadicon

n/a no

library

loadlibrary

freelibrary

yesmemory

allocdstocsalias

freeselector

yesallocselector

freeselector

yesglobalalloc

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

yespalette

createpalette

deleteobject

yespen

createpen

deleteobject

yescreatepenindirect

deleteobject

yesregions

createellipticrgn

deleteobject

yescreateellipticrgnindirect

deleteobject

yescreatepolygonrgn

deleteobject

yescreatepolypolygonrgn

deleteobject

yescreaterectrgn

deleteobject

yescreaterectrgnindirect

deleteobject

yescreateroundrectrgn

deleteobject

yesresource

allocresource

freeresource no

findresource

n/a no

load

resource

freeresource no

lockresource

unlockresource no

sound

opensound

closesound

yesstring

loadstring

n/a no

thunk

makeprocinstance

freeprocinstance no

timer

settimer

killtimer no

window

createwindow

destroywindow no

createwindowex

destroywindow no

從cgdiobject類派生的類如cfont cbrush,析構時會自動deleteobject。

但是在銷毀物件之前,要先把物件從dc中選出(否則deleteobject會失敗)。 *

位圖資源在釋放的時候必須從選中它的dc中脫離。

%當選單失去焦點和視窗不再關聯或者應用程式結束的時候占用資源必須被釋放。

@dc被釋放前必須和它關聯(選中)的點陣圖取消聯絡

#如果脫字元指定了點陣圖,位圖必須被釋放

&對deleteobject的呼叫不會銷毀常規的stockobject(系統內定資源)

VC釋放資源檔案DLL,EXE等。。。

name releaseresfile brief 釋放資源檔案 param word wresid 資源id param lpctstr szrestype 資源型別 param lpctstr szfilename 釋放後的檔名稱 return 成功true,釋放false bool relea...

科銳課堂筆記 2017 3 25 資源分配釋放規定

在定義乙個資源變數標識時,應賦予初始表分配失敗的錯誤值 如常見的null 每次向系統申請資源或呼叫功能介面時,判斷其錯誤處理,如結果失敗goto跳轉到函式末尾將對程式當前獲取的所有資源進行統一釋放。函式末尾返回前,有一段 將依次釋放所有已分配或占有的裝置資源,釋放前應先判斷變數是否有效,釋放後標記資...

VC中釋放程式中地資源到檔案

方法一 使用createfile和writefile lpvoid lp lockresource gl 查詢,載入,鎖定資源 bool bexist ffind.findfile strfilename 判斷檔案是否存在 ffind.close if bexist 如果檔案不存在則建立 方法2 使...