锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
鍦?/span>ATL Server涓紝涓嬪垪鐨勯儴鍒嗗凡緇忓叕寮
錛?錛?span> Core ATL Server Framework classes in atlisapi.h, atlstencil.h, atlserr.h
錛?錛?span> Caching classes in atlcache.h
錛?錛?span> Cryptography classes in atlcrypt.h
錛?錛?span> HTML generation on server side and reading on client sides in atlhtml.h
錛?錛?span> Performance monitoring classes in atlperf.h
錛?錛?span> Extension management classes in atlextmgmt.h
錛?錛?span> Server and client side support for SOAP based Web services in atlsharedsvc.h, atlsoap.h
錛?錛?span> Session-state classes and interfaces in atlsession.h
錛?錛?span> MIME/SMTP support in atlmime.h and atlsmtpconnection.h
錛?0錛?nbsp;Regular Expression support from atlrx.h
錛?1錛?nbsp;Stream helpers in atlsoap.h and atlhtml.h
錛?2錛?nbsp;Many of the ATL Server tutorials, samples and help pages.
涓嬭〃鍒楀嚭浜嗗叕寮鐨勬簮鏂囦歡錛岃繖浜涙簮鏂囦歡鍙互鐩存帴鍦ㄧ綉涓婁笅杞姐?/span>
atlcache.h |
atlcrypt.h |
atlcrypt.inl |
atlextmgmt.h |
atlhtml.h |
atlhttp.h |
atlhttp.inl |
atlisapi.h |
atlmime.h |
atlperf.h |
atlperf.inl |
atlrx.h |
atlsession.h |
atlserr.h |
atlsharedsvc.h |
atlsiface.h |
atlsmtpconnection.h |
atlsmtputil.h |
atlsoap.h |
atlsrv.rc |
atlsrvres.h |
atlstencil.h |
res\dllmgr.srf |
res\stencilmgr.srf |
res\threadmgr.srf |
涓嬮潰榪欎簺宸ュ叿鐨勬簮鐮佷篃灝嗕細鍏紑銆?/span>
· clstencil.exe - used in running Request Handler DLLs or SRF Files from the command line
· sproxy.exe - used in generating proxy classes for SOAP based Web Service clients 錛堢敤鏉ョ敓鎴?/span>WEB Service鐨勪唬鐞嗐備互渚夸簬緙栫▼璋冪敤錛?/span>
· vcdeploy.exe - used in deploying ATL Server projects to IIS
浠婂ぉ錛屾湁鐐規椂闂村湪鐪婣TL server鏂歸潰鐨勮祫鏂欍傛墦寮鍓嶉潰璇寸殑緗戠珯錛屽茍鎵懼埌浜嗚繖浜涗笢涓滐紝瀹炰笉鏁㈢嫭浜?a >http://atlserver.codeplex.com/榪欓噷鏈夋垜鍓嶉潰璇寸殑澶存枃浠朵笌宸ュ叿銆?/span>
[
object,
uuid(….),
….
]
Interface IA
{
…
};
//Client;
Class B
{
IA GetIA(..);
};
B b;
CComPtr<IA> aPtr(b.GetIA(…));
榪欐牱瀵艱嚧鎴戠殑涓涓粨鏋勫寲瀛樺偍璧勬簮琚暱涔呭湴鍗犵敤錛屼笉鑳藉垹闄ゃ傛湁浜烘垨璁稿凡緇忕煡閬撻棶棰樼殑鎵鍦ㄤ簡銆傝繖涓敊璇氨鍦ㄤ簬CComPtr<IA> aPtr(b.GetIA(…));榪欐牱浠庢柟娉曚紶鍑烘潵鐨勬帴鍙e氨娌℃湁鑳藉璋冪敤Release錛岃繖鏍鋒硠婕忓氨浜х敓浜嗐傛紜殑浣跨敤搴斿涓?/p>
CComPtr<IA> aPtr錛?/p>
aPtr.Attach(b.GetIA(…));
鎷垮嚭榪欎袱涓柟娉曠殑婧愪唬鐮佸氨闈炲父娓呮浜嗐?/p>
CComPtrBase(_In_opt_ T* lp) throw()
{
p = lp;
if (p != NULL)
p->AddRef();
}
void Attach(_In_opt_ T* p2) throw()
{
if (p)
p->Release();
p = p2;
}
瀵逛簬Detach鍜屾瀽鏋勬柟娉曚笉浼氬洜娣蜂貢閫犳垚闂錛屽洜涓篋etach鎬繪槸鐢ㄤ簬涓涓柟娉曚腑瑕佽繑鍥炰竴涓櫤鑳芥寚閽堢殑瀹為檯鎺ュ彛鏃惰皟鐢ㄤ粠鑰岃揪鍒頒嬌浠g爜綆媧併傝屾瀽鏋勪篃浼氬洜涓哄垎紱誨嚭浜嗘帴鍙f寚閽堣屼笉鍋氫換浣曚簨鎯呫?/p>
鐜板湪鎴戜滑瀹屾垚浜嗗ぇ閮ㄥ垎鐨勫伐浣滐紝灝辯暀涓嬭緝闅劇殑get__NewEnum瀹炵幇銆傚湪鐞嗚В瀹炵幇鏈虹悊鍚庤繖閮ㄥ垎涔熶笉綆楅毦錛岃繖閲屽彧鏄洖欏句竴涓啓浣滆繃紼嬶紝騫朵笉浼氬お澶氬湴璇村師鐞嗭紝璺熺潃鍋氬氨鍙互瀹炵幇涓鑸簲鐢ㄨ姹傜殑闆嗗悎鏋氫婦鍣ㄣ備笉璇村師鐞嗙殑鍘熷洜鏄疉TL寰堝鏉傦紝鑷繁姘村鉤鍙堟湁闄愩傛湁浜鴻MFC搴撴槸涓瓟楝鹼紝鎴戣涓篈TL搴撶殑澶嶆潅搴︿篃涓嶄細姣擬FC搴撳鏄撱侫TL搴撳C++涓殑妯℃澘搴旂敤鍙互璇村彂鎸ュ埌浜嗘瀬鑷淬?br>
EvenNumbers.h鏂囦歡銆?/p>
鐢變簬鎴戜滑鐨勭被緇ф壙浜咺CollectionImpl錛屾墍浠tem, Count榪欎袱涓睘鎬ф垜浠彲浠ヤ笉蹇呰嚜宸卞啀鍘誨疄鐜般傛垜浠彧瑕佸疄鐜癈alc鏂規硶 鍙奯NewEnum灞炴т簡銆傝繖閲屼嬌鐢ˋTL寮鍙戝皬緇勬彁渚涚殑鏂囦歡VCUE_Collection銆傛墍浠ュ彧闇涓琛屼唬鐮佸氨瑙e喅榪欎釜闂銆傚涓嬶細
鍒版灝卞仛濂戒竴涓泦鍚堟灇涓懼櫒鐨勪緥瀛愩傚彲浠ュ湪C#涓嬌鐢ㄣ傚涓嬨?br> foreach(object obj in evenNumbers)
{ Console.WriteLine(obj.ToString()); }
Sample: http://www.shnenglu.com/Files/Robertxiao/MyCollection.rar
絎竴縐嶈娉?/span>:鏄竴縐嶉昏緫涓婄殑鍙嶉鏈哄埗,榪欑鏈哄埗鍏佽瀵硅薄鏆撮湶鍏?/span>”璋冪敤涓涓垨鑰呭涓寚瀹氭帴鍙g殑鑳藉姏”
絎簩縐嶈娉?/span>:QueryInterface鍏佽瀹㈡埛浠庡璞′腑鍙栧緱涓涓寚鍚戝璞″疄鐜扮殑鎺ュ彛鎸囬拡,榪炴帴鐐瑰厑璁稿鎴風粰浜堝璞′竴涓敱瀹㈡埛瀹炵幇鐨勬帴鍙f寚閽?/span>.
鍦ㄨ繖縐嶆儏褰笅:COM瀵硅薄鏄簮,瀹㈡埛鎻愪緵鐨勬柟娉曟槸鎺ユ敹鍣?/span>.
婧愬繀欏誨疄鐜?/span>IConnectionPoint
Interface IConnectionPoint
{
HRESULT GetConnectionInterface([out] IID *pIID);
HRESULT GetConnectionPointContainer([out] IConnectionPointContainer** ppCPC);
HRESULT Advise([in] IUnknnown *punkSing, [Out] DWORD *pdwCookie);
HRESULT Unadvise([in]DWORD dwCookie);
HREUSLT EnumConnections([out] IEnumConnections** ppEnum);
}
Interface IConnectionPointContainer
{
HRESULT EnumConnectionPoints([out] IEnumConnectionPoints **ppEnum);
HRESULT FindConnectionPoint([in] REFIID riid, [out] IConnectionPoint **ppcP);
}
瀹㈡埛鐨勪嬌鐢ㄦ柟娉?/span>:
IUnKnown *pSource;
ISpeakerEvent *pSink;
DWORD dwCookie;
IConnectionPointContainer pcpc;
Hr = pSource->QueryInterface(&pcpc);
IConnectionPoint pcp;
Hr = pcpc->FindConnection(__uuidof(ISpeakerEvent));
Hr = pcp->Advise(pSink,&dwCookie);
Hr = pcp->Unadvise(dwCookie);
渚挎嵎鐨勭殑瀹?/span>:
AtlAdivse(psource, pSink, __uuidof(ISpeakerEvent), &dwCookie);
AtlUnadvise(psource, __uuidof(ISpeakerEvent), dwCookie);
寤虹珛鍙繛鎺ュ璞$殑姝ヨ仛:
1:瀹炵幇IConnectionPointContainer鎺ュ彛
Class ATL_NO_VTABLE className:
….
Public IConnectionPointContainerImpl<className>
{…..
};
2:QueryInterface瀵?/span>DIID_IConnectionPointContainer鐨勮姹備綔鍑哄搷搴?/span>
BEGIN_COM_MAP
…
COM_INTERFACE_ENTRY(IConnectionPointContainer)
END_COM_MAP
3:鎴戜滑瑕佷負姣忎釜鍙繛鎺ュ璞℃敮鎸佺殑婧愭帴鍙e疄鐜?/span>IConnectionPoint
Class ATL_NO_VTABLE className:
….
Public IConnectionPointContainerImpl<className>,
Public IConnectionPointImpl<className, &DIID__瀵瑰鐨勬帴鍙?/span>>
{…..
};
4:鎴戜滑瑕佹彁渚涗竴涓繛鎺ユ槧灝勮〃,涔熷氨鏄竴涓?/span>IID鍜岃繛鎺ョ偣瀹炵幇鑱旂郴璧鋒潵鐨勮〃.
BEGIN_CONNECTION_POINT_MAP
CONNECTION_POINT_MAP_ENTRY(DIID__瀵瑰鐨勬帴鍙?/span>)
….
END_CONNECTION_POINT_MAP()
5:鎴戜滑蹇呴』鏇存柊鍙繛鎺ュ璞″湪IDL鏂囦歡涓?/span>coClass鐨勫畾涔?/span>,浠ヤ究鎸囧畾姣忎釜婧愭帴鍙?/span>.姣忎釜婧愭帴鍙e繀欏誨叿鏈夊睘鎬?/span>,涓繪簮鎺ュ彛搴斿叿鏈?/span>[default, source]灞炴?/span>.
Coclass 綾誨巶鍚?/span>
{……
[default,source] dispinterface _瀵瑰鎺ュ彛;
};
6:涓鑸潵璇?/span>,鎴戜滑甯屾湜閫氳繃杈呭姪鏂規硶涓烘墍鏈夎繛鎺ョ殑鎺ユ敹鍣ㄨ皟鐢ㄦ帴鏀跺櫒鏂規硶.
HRESULT Fire_浜嬩歡(parameter)
{
渚濇璋冪敤姣忎釜鎺ユ敹鍣ㄧ殑鏂規硶
}
鍙互浣跨敤IDE鏉ョ敓鎴愯繛鎺ョ偣浠g悊綾?/span>.榪欐牱鎴戜滑鐨勬簮鍙互浠庡叾媧劇敓,鑰屼笉鍐嶄粠IConnectionPointImpl媧劇敓.
7:鎴戜滑蹇呴』鍦ㄩ傚綋鐨勬椂鏈鴻皟鐢ㄨ緟鍔╂柟娉?/span>.
寤虹珛鎺ユ敹浜嬩歡鐨勫璞?/span>:
1:瀹炵幇浜嬩歡鎺ユ敹鍣?/span>.鍙厛鐨勬柟妗堟湁浠?/span>
IDispEventSimpleImpl<UINT nID, class T, const IID *pdIID = &IID_NULL>
鎴栬?/span>:
IDispEventImpl< UINT nID, class T, const IID *pdIID = &IID_NULL,
Const GUID*plibid= &GUID_NULL,
DWORD wMajor = 0, WORD wMinor = 0,
Class tihclass = CComTypeInfoHolder>
媧劇敓.
渚嬪:
static const int DEFSOURCEID = 1;
class CEarPolitic;
typedef IDispEventImpl< DEFSOURCEID, CEarPolitic, &DIID__ISpeackerEvents
&LIBID_ATLINTERNALSLIB, LIBMAJOR,LIBMINOR> DefSource;
Class ATL_NO_VTABLE CEarPolitic
:public DefSource
{
….
}
2:浜嬩歡鎺ユ敹鍣ㄦ槧灝勮〃
BEGIN_SINK_MAP(CEarPolitic)
SINK_ENTRY_EX(source, DIID, DISPID, EventHandlerFunc)
SINK_ENTRY_EX(source, DIID, DISPID, EventHandlerFunc, &info)
END_SINK_MAP()
渚嬪:
void __stdcall OnHearPlaintiffWhisper(BSTR bstrText);//sink鎺ュ彛鐨勪竴涓柟娉?/span>.
_ATL_FUNC_INFO OnHearPlaintiffWhisper =
{CC_STDCALL, VT_EMPTY, 1, { VT_BSTR}};
Static const int SOURCEID = 1;
BEGIN_SINK_MAP(CEarPolitic)
SINK_ENTRY_EX(SOURCEID, DIID__瀵瑰鎺ュ彛, 鏂規硶鐨?/span>DISPID, OnHearPlaintiffWhisper)
END_SINK_MAP()
3:榪涗竴姝ュ疄鐜拌繖涓洖璋冨嚱鏁?/span>.
4:鎶婁簨浠舵帴鏀跺櫒榪炴帴鍒版暟鎹簮
Hello |
Hello | |||
Client Stub | Server Stub | |||
Client Runtime Liberary | Server RuntimeLiberary | |||
Transport | Transport |