锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产成人久久精品影视,久久这里都是精品,亚洲国产欧美国产综合久久http://www.shnenglu.com/HeavenOnProg/钑存棤娉曚簬鏈夋硶錛屽寲鏈夐檺涓烘棤闄?/description>zh-cnSat, 28 Jun 2025 07:49:51 GMTSat, 28 Jun 2025 07:49:51 GMT60- ATL瀵規(guī)帴鍙f煡璇㈢殑鏀寔http://www.shnenglu.com/HeavenOnProg/archive/2007/04/30/23233.htmlmichaelmichaelMon, 30 Apr 2007 03:37:00 GMThttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/30/23233.htmlhttp://www.shnenglu.com/HeavenOnProg/comments/23233.htmlhttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/30/23233.html#Feedback0http://www.shnenglu.com/HeavenOnProg/comments/commentRss/23233.htmlhttp://www.shnenglu.com/HeavenOnProg/services/trackbacks/23233.htmlCOM瀵硅薄瀹炵幇鎺ュ彛鐨勬柟娉曟槸澶氱澶氭牱鐨勶紝甯哥敤鐨勬湁澶氶噸緇ф壙銆佽仛鍚堛乼ear-off絳夈備負(fù)浜?jiǎn)鏈澶ч檺搴﹀湴鏀寔鎺ュ彛鏌ヨ鐨勫鏍鋒э紝ATL浣跨敤琛ㄩ┍鍔ㄧ殑鏂瑰紡鏉ョ鐞嗘帴鍙f煡璇紝浠ュ仛鍒頒唬鐮佸皝闂拰鎵╁睍鐏墊椿錛岃〃鏉$洰鏍煎紡涓猴細(xì)
struct
聽(tīng)_ATL_INTMAP_ENTRY
{
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
const
聽(tīng)I(yíng)ID
*
聽(tīng)piid;聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)DWORD_PTR聽(tīng)dw;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)_ATL_CREATORARGFUNC
*
聽(tīng)pFunc;聽(tīng)
};
piid鏄帴鍙D錛宒w涓鴻嚜瀹氫箟鍙傛暟錛宲Func鏄嚜瀹氫箟鍑芥暟鐨勫湴鍧銆傚湪QueryInterface鏃訛紝ATL璋冪敤pFunc錛屽茍灝哾w浼犵粰pFunc錛宲Func鍙互鏍規(guī)嵁鑷繁鐨勯渶瑕佽В鏋恉w錛岃幏寰楁煡璇㈠繀闇鐨勪俊鎭侫TL棰勬彁渚涗簡(jiǎn)涓浜涘嚱鏁版潵澶勭悊涓婅堪甯哥敤鐨勬煡璇㈣姹傦紝濡俖Creator銆乢Delegate絳夛紝瀹冧滑琚斁緗簬CComObjectRootBase涓?br />
錛?錛夊閲嶇戶(hù)鎵?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ATL騫舵病鏈夋彁渚涙敮鎸佸閲嶇戶(hù)鎵跨殑鍑芥暟錛岃屾槸灝唒Func璁劇疆涓篲ATL_SIMPLEMAPENTRY瀹忥紝灝哾w璁句負(fù)鐖剁被瀛愬璞″湪瀛愮被瀵硅薄涓殑鍋忕Щ閲忥紝褰撴悳绱㈣〃鏃跺彂鐜皃Func涓篲ATL_SIMPLEMAPENTRY鏃訛紝渚跨洿鎺ヤ嬌鐢ㄥ亸縐婚噺鐩稿姞鑾峰緱緇撴灉銆?/p>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)if
聽(tīng)(pEntries
->
pFunc聽(tīng)
==
聽(tīng)_ATL_SIMPLEMAPENTRY)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)I(yíng)Unknown
*
聽(tīng)pUnk聽(tīng)
=
聽(tīng)(IUnknown
*
)((INT_PTR)pThis
+
pEntries
->
dw);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)pUnk
->
AddRef();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
*
ppvObject聽(tīng)
=
聽(tīng)pUnk;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return
聽(tīng)S_OK;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鎺ュ彛鏄犲皠琛ㄩ」瀹忎負(fù)錛?/p>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)#define
聽(tīng)COM_INTERFACE_ENTRY(x)\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
&
_ATL_IIDOF(x),聽(tīng)\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)offsetofclass(x,聽(tīng)_ComMapClass),聽(tīng)\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_ATL_SIMPLEMAPENTRY},
錛?錛夎仛鍚?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ATL浣跨敤_Delegate鍑芥暟鏉ユ敮鎸佽仛鍚堬紝姝ゆ椂dw瀛樺偍鐨勬槸鍐呴儴瀵硅薄鎸囬拡鎴愬憳鍙橀噺鍦ㄥ閮ㄥ璞′腑鐨勫亸縐婚噺錛宊Delegate鍒╃敤姝ゅ亸縐婚噺鑾峰緱鍐呴儴瀵硅薄鎸囬拡錛岀劧鍚庡皢鏌ヨ璋冪敤濮旀墭緇欏畠銆?/p>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static
聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_Delegate(
void
*
聽(tīng)pv,聽(tīng)REFIID聽(tīng)iid,聽(tīng)
void
**
聽(tīng)ppvObject,聽(tīng)DWORD_PTR聽(tīng)dw)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)hRes聽(tīng)
=
聽(tīng)E_NOINTERFACE;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)I(yíng)Unknown
*
聽(tīng)p聽(tīng)
=
聽(tīng)
*
(IUnknown
**
)((DWORD_PTR)pv聽(tīng)
+
聽(tīng)dw);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if
聽(tīng)(p聽(tīng)
!=
聽(tīng)NULL)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)hRes聽(tīng)
=
聽(tīng)p
->
QueryInterface(iid,聽(tīng)ppvObject);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return
聽(tīng)hRes;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鎺ュ彛鏄犲皠琛ㄩ」瀹忎負(fù)錛?br />
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)#define聽(tīng)COM_INTERFACE_ENTRY_AGGREGATE(iid,聽(tīng)punk)\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){&iid,\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)(DWORD_PTR)offsetof(_ComMapClass,聽(tīng)punk),\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_Delegate},
聽(tīng)聽(tīng)聽(tīng)
錛?錛塼ear-off
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ATL浣跨敤_Creator鍑芥暟鏉ユ敮鎸乼ear-off錛屾鏃禿w涓瓨鍌ㄧ殑鏄竴涓潤(rùn)鎬乢ATL_CREATORDATA緇撴瀯鐨勫湴鍧錛宊Creator鍒╃敤鍏朵腑鐨勬寚鍚戝垱寤哄嚱鏁扮殑鎸囬拡鍒涘緩涓涓猼ear-off瀵硅薄銆?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_Creator(void*聽(tīng)pv,聽(tīng)REFIID聽(tīng)iid,聽(tīng)void**聽(tīng)ppvObject,聽(tīng)DWORD_PTR聽(tīng)dw)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_ATL_CREATORDATA*聽(tīng)pcd聽(tīng)=聽(tīng)(_ATL_CREATORDATA*)dw;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)pcd->pFunc(pv,聽(tīng)iid,聽(tīng)ppvObject);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鎺ュ彛鏄犲皠琛ㄩ」瀹忎負(fù)錛?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)#define聽(tīng)COM_INTERFACE_ENTRY_TEAR_OFF(iid,聽(tīng)x)\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){&iid,\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)(DWORD_PTR)&ATL::_CComCreatorData<\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ATL::CComInternalCreator<聽(tīng)ATL::CComTearOffObject<聽(tīng)x聽(tīng)>聽(tīng)>\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)>::data,\
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_Creator},
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_ComCreatorData鐨勭浉鍏沖畾涔夊涓嬶細(xì)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
struct聽(tīng)_ATL_CREATORDATA
{
聽(tīng)聽(tīng)聽(tīng)聽(tīng)_ATL_CREATORFUNC*聽(tīng)pFunc;
};
template聽(tīng)<class聽(tīng)Creator>
class聽(tīng)_CComCreatorData
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)_ATL_CREATORDATA聽(tīng)data;
};
template聽(tīng)<class聽(tīng)Creator>
_ATL_CREATORDATA聽(tīng)_CComCreatorData<Creator>::data聽(tīng)=聽(tīng){Creator::CreateInstance};
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鎴戜滑榪樺彲浠ュ畾涔夎嚜宸辯殑鎺ュ彛鏌ヨ杈呭姪鍑芥暟鍜岃緟鍔╂暟鎹紝閫氳繃dw鍜宲Func鏉ュ畬鎴愬悇縐嶅崈濂囩櫨鎬殑鎺ュ彛瀹炵幇鏂瑰紡錛岄渶瑕佺殑鍙槸鎯寵薄鍔涖?img src ="http://www.shnenglu.com/HeavenOnProg/aggbug/23233.html" width = "1" height = "1" />
]]>- ATL瀵瑰璞″垱寤虹殑鏀寔http://www.shnenglu.com/HeavenOnProg/archive/2007/04/10/21605.htmlmichaelmichaelTue, 10 Apr 2007 09:36:00 GMThttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/10/21605.htmlhttp://www.shnenglu.com/HeavenOnProg/comments/21605.htmlhttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/10/21605.html#Feedback0http://www.shnenglu.com/HeavenOnProg/comments/commentRss/21605.htmlhttp://www.shnenglu.com/HeavenOnProg/services/trackbacks/21605.html聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鍦ˋTL涓紝class factory綾誨拰鏅氱被瀵硅薄鐨勫垱寤洪兘鍙互閫氳繃琚О涓衡滃垱寤鴻呪濈殑妯℃澘綾繪潵鍒涘緩銆?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
template聽(tīng)<class聽(tīng)T1>
class聽(tīng)CComCreator
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)CreateInstance(void*聽(tīng)pv,聽(tīng)REFIID聽(tīng)riid,聽(tīng)LPVOID*聽(tīng)ppv)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)hRes聽(tīng)=聽(tīng)E_OUTOFMEMORY;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)T1*聽(tīng)p聽(tīng)=聽(tīng)NULL;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)p聽(tīng)=聽(tīng)new聽(tīng)T1(pv);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)if聽(tīng)(p聽(tīng)!=聽(tīng)NULL)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)p->SetVoid(pv);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)p->InternalFinalConstructAddRef();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)hRes聽(tīng)=聽(tīng)p->FinalConstruct();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)p->InternalFinalConstructRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)if聽(tīng)(hRes聽(tīng)==聽(tīng)S_OK)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)hRes聽(tīng)=聽(tīng)p->QueryInterface(riid,聽(tīng)ppv);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)if聽(tīng)(hRes聽(tīng)!=聽(tīng)S_OK)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)delete聽(tīng)p;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)hRes;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
};
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鈥滃垱寤鴻呪濋氳繃鎻愪緵涓涓潤(rùn)鎬佸嚱鏁癈reateInstance鏉ュ垱寤烘寚瀹氱被鐨勫疄渚嬶紝騫朵笖鏌ヨ鎸囧畾鐨勬帴鍙c傜涓涓弬鏁板湪瀹炰緥鍖栨櫘閫氬璞″拰class factory瀵硅薄鏃朵細(xì)鏈変笉鍚岋細(xì)瀵逛簬鏅氬璞★紝閫氬父浼?xì)浼犻掕仛鍚堝閮ㄥ璞$殑IUnknown鎸囬拡錛屽鏋滄槸闈炶仛鍚堝垱寤猴紝鍙互浼犻扤ULL錛堣瑙丄TL瀵笴OM瀹炰綋韜喚鐨勬敮鎸佸洓錛夛紱紼嶅悗浼?xì)浠嬀l嶅湪class factory鍒涘緩鏃剁涓涓弬鏁扮殑鐢ㄥ銆?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鍦ˋTL涓紝涓涓猚lass factory瀵硅薄鍙兘鍒涘緩涓縐嶇被鍨嬬殑COM綾誨疄渚嬨傚湪class factory鐨凜reateInstance鍑芥暟涓紝瀹冧笉鏄‖緙栫爜琚垱寤虹殑瀵硅薄綾誨瀷錛岃屾槸閫氳繃涓涓?em>鍑芥暟鎸囬拡鎴愬憳鍙橀噺鏉ュ垱寤哄畠鎵綆$悊鐨勫璞★紝鑰岃繖涓嚱鏁版寚閽堟寚鍚戠殑閫氬父灝辨槸鏌愪釜COM綾葷殑鈥滃垱寤鴻呪濈被鐨凜reateInstance闈?rùn)鎬佸嚱鏁扮殑鍦板潃錛屾鍦板潃鏄湪class factory瀵硅薄琚畠鑷韓鐨勨滃垱寤鴻呪濈殑CreateInstance鍑芥暟鍒涘緩鏃墮氳繃絎竴涓弬鏁頒紶榪涙潵鐨勶紝class factory閲嶆柊瀹氫箟浜?jiǎn)SetVoid鍑芥暟錛屽茍涓斾繚瀛樿繖涓湴鍧錛?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
class聽(tīng)CComClassFactory聽(tīng):
聽(tīng)聽(tīng)聽(tīng)聽(tīng)public聽(tīng)I(yíng)ClassFactory,
聽(tīng)聽(tīng)聽(tīng)聽(tīng)public聽(tīng)CComObjectRootEx<CComGlobalsThreadModel>
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)//聽(tīng)I(yíng)ClassFactory
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD(CreateInstance)(LPUNKNOWN聽(tīng)pUnkOuter,聽(tīng)REFIID聽(tīng)riid,聽(tīng)void**聽(tīng)ppvObj)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)hRes聽(tīng)=聽(tīng)E_POINTER;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)if聽(tīng)(ppvObj聽(tīng)!=聽(tīng)NULL)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)*ppvObj聽(tīng)=聽(tīng)NULL;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)if聽(tīng)((pUnkOuter聽(tīng)!=聽(tīng)NULL)聽(tīng)&&聽(tīng)!InlineIsEqualUnknown(riid))
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)hRes聽(tīng)=聽(tīng)CLASS_E_NOAGGREGATION;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)hRes聽(tīng)=聽(tīng)m_pfnCreateInstance(pUnkOuter,聽(tīng)riid,聽(tīng)ppvObj);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)hRes;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD(LockServer)(BOOL聽(tīng)fLock)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)if聽(tīng)(fLock)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_pAtlModule->Lock();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_pAtlModule->Unlock();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)S_OK;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)void聽(tīng)SetVoid(void*聽(tīng)pv)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)m_pfnCreateInstance聽(tīng)=聽(tīng)(_ATL_CREATORFUNC*)pv;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)_ATL_CREATORFUNC*聽(tīng)m_pfnCreateInstance;
};
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鏍規(guī)嵁涓婇潰鐨勮璁猴紝涓涓狢OM綾葷殑鍒涘緩鑰呬細(xì)鍍忚繖涓牱瀛愶細(xì)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComCreator<聽(tīng)CComObject<CMyClass> >
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鑰屼竴涓猚lass factory鐨勫垱寤鴻呬細(xì)鍍忚繖涓牱瀛愶細(xì)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComCreator< CComCachedObject<CComClassFactory> >銆?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ATL鍦ㄥ鎴瘋姹傚垱寤篊MyClass瀵硅薄鏃舵墽琛岀殑浼唬鐮佸涓嬶細(xì)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
typedef聽(tīng)CComCreator<聽(tīng)CComCachedObject<CComClassFactory>聽(tīng)>聽(tīng)CClassFactoryCreator;
typedef聽(tīng)CComCreator<聽(tīng)CComObject<CMyClass>聽(tīng)>聽(tīng)CMyClassCreator;
IClassFactory*聽(tīng)pcf=NULL;
CClassFactoryCreator::CreateInstance(&CMyClassCreator::CreateInstance,__uuidof(IClassFactory),&pcf);
pcf->CreateInstance(pOuter,__uuidof(IMyInterface),ppvObj);

]]> - ATL瀵笴OM瀹炰綋韜喚鐨勬敮鎸侊紙鍥涳級(jí)鈥斺?CComObject鍙?qiáng)鍏朵紮浼?/title>http://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21408.htmlmichaelmichaelFri, 06 Apr 2007 07:33:00 GMThttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21408.htmlhttp://www.shnenglu.com/HeavenOnProg/comments/21408.htmlhttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21408.html#Feedback0http://www.shnenglu.com/HeavenOnProg/comments/commentRss/21408.htmlhttp://www.shnenglu.com/HeavenOnProg/services/trackbacks/21408.html
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鏈変簡(jiǎn)CComObjectRootBase銆丆ComObjectRootEx鍜岀嚎紼嬫ā鍨嬬壒寰佺被榪欎簺鍩虹鍘熸枡錛孋ComObject鍜屽畠鐨勪紮浼翠滑渚垮彲浠ヨ嚜鐢辯殑鍙戞尌瀹冧滑鐨勬兂璞′簡(jiǎn)銆?br />
1.CComObject 鈥斺?鏅氬爢瀵硅薄聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)涓嬮潰鏄簿綆鐨凜ComObject妯℃澘綾葷殑瀹氫箟錛毬?tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)?/p>
template聽(tīng)
<
class
聽(tīng)Base
>
class
聽(tīng)CComObject聽(tīng):聽(tīng)
public
聽(tīng)Base
{
public
:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComObject(
void
*
聽(tīng)
=
聽(tīng)NULL)聽(tīng)
throw
()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_pAtlModule
->
Lock();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)virtual
聽(tīng)
~
CComObject()聽(tīng)
throw
()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)FinalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) _pAtlModule
->
Unlock();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng) STDMETHOD_(ULONG,聽(tīng)AddRef)()聽(tīng){
return
聽(tīng)I(yíng)nternalAddRef();}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)Release)()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ULONG聽(tīng)l聽(tīng)
=
聽(tīng)I(yíng)nternalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if
聽(tīng)(l聽(tīng)
==
聽(tīng)
0
)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)delete聽(tīng)
this
;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return
聽(tīng)l;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD(QueryInterface)(REFIID聽(tīng)iid,聽(tīng)
void
聽(tīng)
**
聽(tīng)ppvObject)聽(tīng)
throw
()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
return
聽(tīng)_InternalQueryInterface(iid,聽(tīng)ppvObject);}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
static
聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)CreateInstance(CComObject
<
Base
>**
聽(tīng)pp)聽(tīng)
throw
();
};
鈥滄櫘閫氬爢瀵硅薄鈥濇槸浣跨敤鏈涓洪綣佺殑綾伙紝瀹冩湁濡備笅鐗瑰緛錛?br />錛?錛夊湪鍫嗕腑鍒嗛厤鍐呭瓨 鈥斺?璁℃暟褰掗浂鏃剁敤delete閿姣?br />錛?錛夋敮鎸佺嫭绔嬪瓨鍦ㄧ殑瀵硅薄 鈥斺?浣跨敤InternalXXX鏉ュ疄鐜癐Unknown鍔熻兘
錛?錛変駭鐢熸椂閿佸畾鏈嶅姟鍣紝閿姣佹椂瑙i攣鏈嶅姟鍣?鈥斺?閫傜敤浜庡ぇ澶氭暟COM瀵硅薄
2. CComAggObject 鈥斺?琚仛鍚堝爢瀵硅薄
template聽(tīng)
<
class
聽(tīng)contained
>
class
聽(tīng)CComAggObject聽(tīng):
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
public
聽(tīng)I(yíng)Unknown,
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
public
聽(tīng)CComObjectRootEx
<
聽(tīng)typename聽(tīng)contained::_ThreadModel::ThreadModelNoCS聽(tīng)
>
{
public
:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComAggObject(
void
*
聽(tīng)pv)聽(tīng):聽(tīng)m_contained(pv)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_pAtlModule
->
Lock();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
HRESULT聽(tīng)FinalConstruct()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComObjectRootEx
<
contained::_ThreadModel::ThreadModelNoCS
>
::FinalConstruct();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return
聽(tīng)m_contained.FinalConstruct();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
void
聽(tīng)FinalRelease()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComObjectRootEx
<
contained::_ThreadModel::ThreadModelNoCS
>
::FinalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)m_contained.FinalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)
聽(tīng)
virtual
聽(tīng)
~
CComAggObject()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)FinalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)_pAtlModule
->
Unlock();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)AddRef)()聽(tīng){
return
聽(tīng)I(yíng)nternalAddRef();}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)Release)()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ULONG聽(tīng)l聽(tīng)
=
聽(tīng)I(yíng)nternalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if
聽(tīng)(l聽(tīng)
==
聽(tīng)
0
)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)delete聽(tīng)
this
;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return
聽(tīng)l;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD(QueryInterface)(REFIID聽(tīng)iid,聽(tīng)
void
聽(tīng)
**
聽(tīng)ppvObject)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)hRes聽(tīng)
=
聽(tīng)S_OK;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if
聽(tīng)(InlineIsEqualUnknown(iid))
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
*
ppvObject聽(tīng)
=
聽(tīng)(
void
*
)(IUnknown
*
)
this
;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)AddRef();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)hRes聽(tīng)
=
聽(tīng)m_contained._InternalQueryInterface(iid,聽(tīng)ppvObject);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return
聽(tīng)hRes;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)
聽(tīng)
static
聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)CreateInstance(LPUNKNOWN聽(tīng)pUnkOuter,聽(tīng)CComAggObject
<
contained
>**
聽(tīng)pp)錛?br />
聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComContainedObject
<
contained
>
聽(tīng)m_contained;
};
聽(tīng) CComAggObject鏈夊涓嬬壒寰侊細(xì)
錛?錛夊湪鍫嗕腑鍒嗛厤鍐呭瓨
錛?錛夋敮鎸佽鑱氬悎鑱氬悎鐨勫璞?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)瀹炵幇浜?jiǎn)涓や唤IUnknown錛欳ComAggObject瀹炵幇浜?jiǎn)鍐呴儴鑱氬悎绫荤湡姝g殑IUnknown錛屽畠綆$悊瀵硅薄鐨勭敓瀛樻湡錛屽茍涓斿畬鎴愭帴鍙f煡璇紙閫氳繃contained瀵硅薄鐨刜InternalQueryInterface錛夛紱contained瀵硅薄瀹炵幇浜?jiǎn)鍏锋湁铦{鍙戝姛鑳界殑IUnknown錛屽畠?yōu)畣鎵鏈夌殑璋冪敤杞彂緇機(jī)ComAggObject鍦ㄦ瀯閫犲嚱鏁頒腑鏀跺埌鐨勫閮↖Unknown鎸囬拡銆?br />錛?錛変駭鐢熸椂閿佸畾鏈嶅姟鍣紝閿姣佹椂瑙i攣鏈嶅姟鍣?br />
3. CComTearOffObject 鈥斺?tear-off 瀵硅薄
template聽(tīng)
<
class
聽(tīng)Base
>
class
聽(tīng)CComTearOffObject聽(tīng):聽(tīng)
public
聽(tīng)Base
{
public
:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComTearOffObject(
void
*
聽(tīng)pv)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)m_pOwner聽(tīng)
=
聽(tīng)reinterpret_cast
<
Base::_OwnerClass
*>
(pv);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)m_pOwner
->
AddRef();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
~
CComTearOffObject()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)FinalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)m_pOwner
->
Release();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)AddRef)()聽(tīng)
throw
()聽(tīng){
return
聽(tīng)I(yíng)nternalAddRef();}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)Release)()聽(tīng)
throw
()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ULONG聽(tīng)l聽(tīng)
=
聽(tīng)I(yíng)nternalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if
聽(tīng)(l聽(tīng)
==
聽(tīng)
0
)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)delete聽(tīng)
this
;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return
聽(tīng)l;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD(QueryInterface)(REFIID聽(tīng)iid,聽(tīng)
void
聽(tīng)
**
聽(tīng)ppvObject)聽(tīng)
throw
()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return
聽(tīng)m_pOwner
->
QueryInterface(iid,聽(tīng)ppvObject);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
};
聽(tīng)聽(tīng)聽(tīng)tear-off瀵硅薄鏈夊涓嬬壒寰侊細(xì)
錛?錛夊湪鍫嗕腑鍒嗛厤鍐呭瓨
錛?錛夋敮鎸佸湪ATL緇勪歡鍐呴儴浣跨敤鐨則ear-off鎶鏈?br />錛?錛夌敓鎴愭椂閿佸畾鐖跺璞★紝閿姣佹椂瑙i攣鐖跺璞?br />錛?錛夌敓鍛藉懆鏈熺敱鑷繁綆$悊錛屾帴鍙f煡璇㈠鎵樼埗瀵硅薄
4. CComObjectStack 鈥斺?鏍堝璞?br />聽(tīng)聽(tīng)聽(tīng)
template聽(tīng)<class聽(tīng)Base>
class聽(tīng)CComObjectStackEx聽(tīng):聽(tīng)public聽(tīng)Base
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComObjectStackEx(void*聽(tīng)=聽(tīng)NULL)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)m_hResFinalConstruct聽(tīng)=聽(tīng)FinalConstruct();聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)virtual聽(tīng)~CComObjectStackEx()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) FinalRelease();
聽(tīng)聽(tīng)聽(tīng) }
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)AddRef)()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) return聽(tīng)0;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)Release)()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)0;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD(QueryInterface)(REFIID聽(tīng)iid,聽(tīng)void聽(tīng)**聽(tīng)ppvObject)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)_InternalQueryInterface(iid,聽(tīng)ppvObject);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)m_hResFinalConstruct;
};
聽(tīng)聽(tīng)聽(tīng)鏍堝璞℃湁濡備笅鐗瑰緛錛?br />錛?錛夊唴瀛樺垎閰嶄簬鏍堜笂 鈥斺?涓嶉渶瑕佸璞¤冭檻閲婃斁闂
錛?錛夋棤寮曠敤璁℃暟鍔熻兘
錛?錛夋瀯閫犳椂鍒濆鍖?鈥斺?闇瑕佸湪鏋勯犲嚱鏁拌皟鐢ㄥ悗媯(gè)鏌_hResFinalConstruct錛屼互鍒ゆ柇瀵硅薄鏄惁鏋勯犳垚鍔?br />錛?錛変笉閿佸畾鏈嶅姟鍣?br />
5. CComObjectGlobal 鈥斺?鍏ㄥ眬瀵硅薄
template聽(tīng)<class聽(tīng)Base>
class聽(tīng)CComObjectGlobal聽(tīng):聽(tīng)public聽(tīng)Base
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)CComObjectGlobal(void*聽(tīng)=聽(tīng)NULL)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) m_hResFinalConstruct聽(tīng)=聽(tīng)FinalConstruct();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)virtual聽(tīng)~CComObjectGlobal()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)FinalRelease();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)AddRef)()聽(tīng)throw()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)_pAtlModule->Lock();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD_(ULONG,聽(tīng)Release)()聽(tīng)throw()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)_pAtlModule->Unlock();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)STDMETHOD(QueryInterface)(REFIID聽(tīng)iid,聽(tīng)void聽(tīng)**聽(tīng)ppvObject)聽(tīng)throw()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)_InternalQueryInterface(iid,聽(tīng)ppvObject);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)m_hResFinalConstruct;
};
聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)鍏ㄥ眬瀵硅薄鏈夊涓嬬壒寰侊細(xì)
錛?錛夊湪鍏ㄥ眬鏁版嵁鍖哄垎閰嶅唴瀛?br />錛?錛夊垵濮嬪寲鏃朵笉閿佸畾鏈嶅姟鍣紝寮曠敤璁℃暟鍙樺寲鏃舵墠閿佸畾鎴栬呰В閿佹湇鍔″櫒錛岃繖浣垮緱鍏ㄥ眬瀵硅薄鍙互琚敤浜庡叏灞綾誨巶瀵硅薄錛屼互瑙e喅鏈嶅姟鍣ㄥ拰綾誨巶涔嬮棿鐨勬閿侀棶棰?br />錛?錛夋瀯閫犳柟寮忓悓鏍堝璞?br />
聽(tīng)聽(tīng)聽(tīng)榪樻湁涓浜涘叾瀹冪綾葷殑鐢熷瓨鏈熺鐞嗙被錛屽CComObjectNoLock銆丆ComObjectCached銆丆ComPolyObject絳夌瓑錛屽畠浠篃閮芥湁鑷繁鐙埌鐨勭敤澶勶紝鎴戜滑涔熷彲浠ユ牴鎹嚜宸辯殑闇瑕佺紪鍐欒嚜瀹氫箟鐨勭被銆傛諱箣CComObjectRootBase銆丆ComObjectRootEx鍜岀嚎紼嬫ā鍨嬬壒寰佺被灝卞儚鏄Н鏈ㄤ竴鏍鳳紝鎴戜滑鍙互浠繪剰鐨勬妸瀹冧滑緇勫悎鎴愭兂瑕佺殑褰㈢姸銆?img src ="http://www.shnenglu.com/HeavenOnProg/aggbug/21408.html" width = "1" height = "1" />
]]> - ATL瀵笴OM瀹炰綋韜喚鐨勬敮鎸侊紙涓夛級(jí)鈥斺?璁塊棶鍚屾鏀寔http://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21403.htmlmichaelmichaelFri, 06 Apr 2007 06:39:00 GMThttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21403.htmlhttp://www.shnenglu.com/HeavenOnProg/comments/21403.htmlhttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21403.html#Feedback0http://www.shnenglu.com/HeavenOnProg/comments/commentRss/21403.htmlhttp://www.shnenglu.com/HeavenOnProg/services/trackbacks/21403.html
class聽(tīng)CComSingleThreadModel
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)ULONG聽(tīng)WINAPI聽(tīng)I(yíng)ncrement(LPLONG聽(tīng)p)聽(tīng)throw()聽(tīng){return聽(tīng)++(*p);}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)ULONG聽(tīng)WINAPI聽(tīng)Decrement(LPLONG聽(tīng)p)聽(tīng)throw()聽(tīng){return聽(tīng)--(*p);}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)CComFakeCriticalSection聽(tīng)AutoCriticalSection;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)CComFakeCriticalSection聽(tīng)CriticalSection;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)CComSingleThreadModel聽(tīng)ThreadModelNoCS;
};
class聽(tīng)CComMultiThreadModel
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)ULONG聽(tīng)WINAPI聽(tīng)I(yíng)ncrement(LPLONG聽(tīng)p)聽(tīng)throw()聽(tīng){return聽(tīng)I(yíng)nterlockedIncrement(p);}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)ULONG聽(tīng)WINAPI聽(tīng)Decrement(LPLONG聽(tīng)p)聽(tīng)throw()聽(tīng){return聽(tīng)I(yíng)nterlockedDecrement(p);}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)CComAutoCriticalSection聽(tīng)AutoCriticalSection;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)CComCriticalSection聽(tīng)CriticalSection;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)CComMultiThreadModelNoCS聽(tīng)ThreadModelNoCS;
};
鍏朵腑鐨凜FakeCriticalSection瀹氫箟濡備笅錛?br />class聽(tīng)CComFakeCriticalSection
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)Lock()聽(tīng)throw()聽(tīng){聽(tīng)return聽(tīng)S_OK;聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)Unlock()聽(tīng)throw()聽(tīng){聽(tīng)return聽(tīng)S_OK;聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)I(yíng)nit()聽(tīng)throw()聽(tīng){聽(tīng)return聽(tīng)S_OK;聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)Term()聽(tīng)throw()聽(tīng){聽(tīng)return聽(tīng)S_OK;聽(tīng)}
};
榪欎袱涓被鎻愪緵浜?jiǎn)閽堝鐗瑰畾濂楅棿瀵硅薄鐨勫悓姝ユ帶鍒舵敮鎸併?br />CComSingleThreadModel閫傜敤浜庡崟綰跨▼濂楅棿瀵硅薄錛屽畠涓嶉噰鐢ㄤ換浣曠嚎紼嬪悓姝ユ満鍒訛紱CComMultiThreadModel閫傜敤浜庡綰跨▼濂楅棿瀵硅薄錛屽畠浣跨敤win32鐨勫悓姝ユ満鍒舵潵瀹炵幇銆?br />
2.CComObjectRootEx妯℃澘綾?br />template聽(tīng)<class聽(tīng)ThreadModel>
class聽(tīng)CComObjectRootEx聽(tīng):聽(tīng)public聽(tīng)CComObjectRootBase
{
public:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)ThreadModel聽(tīng)_ThreadModel;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)typename聽(tīng)_ThreadModel::AutoCriticalSection聽(tīng)_CritSec;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)typedef聽(tīng)CComObjectLockT<_ThreadModel>聽(tīng)ObjectLock;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)ULONG聽(tīng)I(yíng)nternalAddRef()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)_ThreadModel::Increment(&m_dwRef);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)ULONG聽(tīng)I(yíng)nternalRelease()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)_ThreadModel::Decrement(&m_dwRef);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)void聽(tīng)Lock()聽(tīng){m_critsec.Lock();}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)void聽(tīng)Unlock()聽(tīng){m_critsec.Unlock();}
private:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)_CritSec聽(tīng)m_critsec;
};
瀹冧嬌鐢ㄤ紶鍏ョ殑綰跨▼妯″瀷鐗瑰緛綾繪潵瀹炵幇瀵硅薄鐙珛瀛樺湪鏃舵墍闇瑕佺殑寮曠敤璁℃暟鏀寔錛屽悓鏃舵彁渚涗簡(jiǎn)涓涓柟渚垮璞″紑鍙戜嬌鐢ㄧ殑鍚屾閿侊紝鎴戜滑鍙互浣跨敤榪欎釜閿佹潵瀹屾垚瀵硅嚜瀹氫箟鏁版嵁璁塊棶鐨勪繚鎶ゃ?img src ="http://www.shnenglu.com/HeavenOnProg/aggbug/21403.html" width = "1" height = "1" />
]]> - ATL瀵笴OM瀹炰綋韜喚鐨勬敮鎸侊紙浜岋級(jí)鈥斺?CComObjectRootBasehttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21393.htmlmichaelmichaelFri, 06 Apr 2007 05:51:00 GMThttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21393.htmlhttp://www.shnenglu.com/HeavenOnProg/comments/21393.htmlhttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21393.html#Feedback0http://www.shnenglu.com/HeavenOnProg/comments/commentRss/21393.htmlhttp://www.shnenglu.com/HeavenOnProg/services/trackbacks/21393.html涓嬮潰鏄疌ComObjectRootBase鐨勫叧閿唬鐮侊細(xì)
class
聽(tīng)CComObjectRootBase
{
public
:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)// 鏋勯犳敮鎸?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)//
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)FinalConstruct();
聽(tīng)聽(tīng)聽(tīng)聽(tīng) void聽(tīng)FinalRelease();聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)//聽(tīng)聽(tīng)鎺ュ彛鏌ヨ鏀寔
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)//
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)I(yíng)nternalQueryInterface(void*聽(tīng)pThis,
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)const聽(tīng)_ATL_INTMAP_ENTRY*聽(tīng)pEntries,聽(tīng)REFIID聽(tīng)iid,聽(tīng)void**聽(tīng)ppvObject);
聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_Break(void*,聽(tīng)REFIID聽(tīng)iid,聽(tīng)void**聽(tīng)聽(tīng),聽(tīng)DWORD_PTR聽(tīng));
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_NoInterface(void*聽(tīng)聽(tīng),聽(tīng)REFIID聽(tīng),聽(tīng)void**聽(tīng)聽(tīng),聽(tīng)DWORD_PTR聽(tīng));
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_Creator(void*聽(tīng)pv,聽(tīng)REFIID聽(tīng)iid,聽(tīng)void**ppvObject,聽(tīng)DWORD_PTR聽(tīng)dw);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_Delegate(void*聽(tīng)pv,聽(tīng)REFIID聽(tīng)iid,聽(tīng)void**聽(tīng)ppvObject,聽(tīng)DWORD_PTR聽(tīng)dw);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_Chain(void*聽(tīng)pv,聽(tīng)REFIID聽(tīng)iid,聽(tīng)void**聽(tīng)ppvObject,聽(tīng)DWORD_PTR聽(tīng)dw);
聽(tīng)聽(tīng)聽(tīng) static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_ChainAttr(void*聽(tīng)pv,聽(tīng)REFIID聽(tīng)iid,聽(tīng)void**聽(tīng)ppvObject,聽(tīng)DWORD_PTR聽(tīng)dw);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)static聽(tīng)HRESULT聽(tīng)WINAPI聽(tīng)_Cache(void*聽(tīng)pv,聽(tīng)REFIID聽(tīng)iid,聽(tīng)void**聽(tīng)ppvObject,聽(tīng)DWORD_PTR聽(tīng)dw);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)//聽(tīng) 鑱氬悎鏀寔
聽(tīng)聽(tīng)聽(tīng) //
聽(tīng)聽(tīng)聽(tīng)聽(tīng)ULONG聽(tīng)OuterAddRef()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)m_pOuterUnknown->AddRef();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)ULONG聽(tīng)OuterRelease()
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)m_pOuterUnknown->Release();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)HRESULT聽(tīng)OuterQueryInterface(REFIID聽(tīng)iid,聽(tīng)void聽(tīng)**聽(tīng)ppvObject)
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)return聽(tīng)m_pOuterUnknown->QueryInterface(iid,聽(tīng)ppvObject);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng) //聽(tīng)瀹炰綋韜喚鏀寔
聽(tīng)聽(tīng)聽(tīng) //
聽(tīng)聽(tīng)聽(tīng)聽(tīng)union
聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)long聽(tīng)m_dwRef;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) IUnknown*聽(tīng)m_pOuterUnknown;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)};
};
CComObjectRootBase涓昏鍔熻兘鍒嗕負(fù)錛?br />錛?錛夋瀯閫犳敮鎸侊細(xì)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鍗矲inalConstruct鍜孎inalRelease錛屽畠浠敤浜庡畨鍏ㄧ殑鏋勯犲拰閿姣佸璞°?br />錛?錛夋帴鍙f煡璇㈡敮鎸?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)閫氳繃鎺ュ彛鏄犲皠琛ㄦ潵瀹屾垚鎺ュ彛鏌ヨ鍔熻兘錛岃緇嗗唴瀹硅鍚庨潰鐨勬枃绔犮?br />錛?錛夎仛鍚堢姸鎬佷笅寮曠敤璁℃暟鎿嶄綔鐨勬敮鎸?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鎻愪緵浜?jiǎn)灏咺Unknown璇鋒眰濮旀墭緇欏閮ㄧ粍浠剁殑鏀寔銆傚綋瀵硅薄鐙珛瀛樺湪鏃訛紝瀵瑰紩鐢ㄨ鏁版搷浣滅殑鏀寔琚斁緗簬CComObjectRootEx涓紝鍥犱負(fù)娑夊強(qiáng)鍒頒簡(jiǎn)濂楅棿鍜岃闂悓姝ャ?br />錛?錛夊疄浣撹韓浠芥敮鎸?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)浣垮緱瀵硅薄鍙互鐙珛瀛樺湪鎴栬呰鑱氬悎錛屽洜涓鴻繍琛屾椂鍒誨璞″彧鑳戒互涓縐嶆柟寮忓瓨鍦紝鎵浠ヤ嬌鐢ㄤ簡(jiǎn)union銆?img src ="http://www.shnenglu.com/HeavenOnProg/aggbug/21393.html" width = "1" height = "1" />
]]> - ATL瀵笴OM瀹炰綋韜喚鐨勬敮鎸侊紙涓錛夆斺?綾誨眰嬈$粨鏋?/title>http://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21382.htmlmichaelmichaelFri, 06 Apr 2007 03:46:00 GMThttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21382.htmlhttp://www.shnenglu.com/HeavenOnProg/comments/21382.htmlhttp://www.shnenglu.com/HeavenOnProg/archive/2007/04/06/21382.html#Feedback0http://www.shnenglu.com/HeavenOnProg/comments/commentRss/21382.htmlhttp://www.shnenglu.com/HeavenOnProg/services/trackbacks/21382.html
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)涓涓狢OM瀵硅薄蹇呴』瀹炵幇IUnknown鎺ュ彛鎵瑙勫畾鐨勫姛鑳斤紝鍗崇敓鍛芥湡綆$悊鍜岃繍琛屾椂綾誨瀷杞崲銆?br />錛?錛夊熀鏈琁Unknow鍔熻兘
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) 瀵硅薄鐨勭敓瀛樻柟寮忓彲浠ユ槸鍫嗗瓨鍌ㄣ佹爤瀛樺偍浠ュ強(qiáng)鍏ㄥ眬瀛樺偍錛屽悓鏃禖OM榪樻彁渚涗簡(jiǎn)涓縐嶈鑱氬悎鐨勭敓瀛樻柟寮忋傜敓瀛樻柟寮忎笉鍚岋紝AddRef銆丷elease鍜孮ueryInterface鐨勫疄鐜版柟寮忓氨涓嶅悓銆傛瘮濡傦細(xì)瀵逛簬鍫嗘柟寮忥紝Release瑕佸湪寮曠敤璁℃暟褰掗浂鏃惰礋璐i噴鏀懼爢絀洪棿錛岃屾爤浠ュ強(qiáng)鍏ㄥ眬鏂瑰紡鍒欎笉蹇咃紱瀵逛簬鑱氬悎鏂瑰紡錛孉ddRef銆丷elease浠ュ強(qiáng)澶ч儴鍒嗙殑QueryInterface璋冪敤瑕佸鎵樼粰澶栭儴瀵硅薄銆?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) 涓轟簡(jiǎn)杈懼埌瀵硅薄鐨勯昏緫鍔熻兘涓庡叾鐢熷瓨鏂瑰紡鐨勫垎紱伙紝COM鎶婂IUnknown鍩烘湰鍔熻兘鐨勫疄鐜版帹榪熷埌綾誨眰嬈$粨鏋勭殑鏈搴曞眰錛屽嵆CComObject錛堟垨瀹冪殑鍏朵粬浼欎即錛夊銆?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) CComObjectRootBase涓篊ComObject鐨勫疄鐜版彁渚涘師鏉愭枡鐨勬敮鎸侊紝濡傛彁渚涘紩鐢ㄨ鏁板彉閲忋佸熀鏈殑鎺ュ彛鏌ヨ鏈哄埗絳夛紝瀹冩槸涓涓滃姛鑳介泦涓被鈥濄?br />錛?錛夊闂村畨鍏ㄦ敮鎸?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) 鏍規(guī)嵁瀵硅薄鎵澶勭殑濂楅棿綾誨瀷錛屽璞″姛鑳界殑瀹炵幇闇瑕佷笉鍚岀殑鍚屾鏀寔銆傚浜庡崟綰跨▼濂楅棿瀵硅薄錛岀敱COM搴撴潵淇濊瘉璁塊棶鐨勫悓姝ワ紱鑰屽浜庡綰跨▼濂楅棿瀵硅薄錛岄渶瑕佽嚜宸辨潵鍚屾璋冪敤銆備負(fù)浜?jiǎn)鋴慑闂村畨鍏ㄦ敮鎸佷笌閫昏緫鍔熻兘鍒嗙錛孉TL鎻愪緵浜?jiǎn)涓緇勬彁渚涚嚎紼嬪畨鍏ㄦ搷浣滄敮鎸佺殑鐗瑰緛綾伙紙traits綾伙級(jí)鈥斺?CComSingleThreadModel鍙?qiáng)鍏朵紮浼淬傚畠浠彁渚涗簡(jiǎn)瀵逛竴涓狶ONG鍙橀噺鈥滄伆濂界嚎紼嬪畨鍏ㄢ濈殑澧炲噺鎿嶄綔錛屼互鍙?qiáng)璺熷闂淳c誨瀷鍖歸厤鐨凜riticalSection鍔熻兘綾匯?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) ATL鍚屾椂鎻愪緵浜?jiǎn)CComObjectRootEx妯℃澘綾伙紝瀹冧互鏌愮ThreadModel鐗瑰緛綾諱綔涓哄弬鏁幫紝鎻愪緵瀵瑰紩鐢ㄨ鏁扳滄伆濂界嚎紼嬪畨鍏ㄢ濈殑鎿嶄綔錛屽茍涓旀彁渚涗簡(jiǎn)涓涓敤浜庡璞″悓姝ョ殑閿併?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)PS:鈥滄伆濂界嚎紼嬪畨鍏ㄢ濈殑鎿嶄綔鐨勬剰鎬濇槸錛氬浜庨渶瑕佺嚎紼嬪悓姝ョ殑瀵硅薄錛屾彁渚泈in32 CriticalSection鏀寔錛涘浜庝笉闇瑕佺殑瀵硅薄錛屽垯浠涔堜篃涓嶅仛銆?br />
]]>
久久夜色精品国产噜噜亚洲AV|
久久精品国内一区二区三区|
精品久久久久久无码人妻热|
久久久免费观成人影院|
国产精品99久久久久久宅男小说|
久久精品人人做人人爽电影|
久久99精品国产|
国产精品综合久久第一页|
少妇人妻88久久中文字幕|
久久亚洲欧洲国产综合|
2021国内久久精品|
久久99精品国产99久久6男男|
亚洲欧美另类日本久久国产真实乱对白|
久久婷婷五月综合97色直播|
国产91久久精品一区二区|
中文字幕无码免费久久|
欧洲性大片xxxxx久久久|
久久精品草草草|
久久九九兔免费精品6|
亚洲国产精品久久久久网站|
色成年激情久久综合|
久久天天躁狠狠躁夜夜躁2O2O|
国内精品久久久久久久影视麻豆|
久久精品99久久香蕉国产色戒|
日韩精品久久久久久免费|
日批日出水久久亚洲精品tv|
国产成人综合久久久久久|
久久久国产精品网站|
91久久精品91久久性色|
国产成人精品综合久久久久|
精品久久久一二三区|
伊人久久五月天|
色婷婷综合久久久久中文|
久久精品中文字幕大胸|
日本久久中文字幕|
欧美亚洲另类久久综合婷婷|
久久九九久精品国产|
中文字幕精品久久久久人妻|
久久香蕉国产线看观看猫咪?v|
久久九色综合九色99伊人|
久久国产美女免费观看精品|