ATL COM connection point 2-3事

一个是 Dispatch interface的实现
一个是 VTABLE的实现。
完整源代码在文章末尾!
server 例子在:
这个用了异步的URL moniker来下载site 上的东西,client用的是 VB。
我空了给写了个C++的client,用的WTL的界面,只是调用了一下COM里的东西
VS2008 的工程,主要是关键 connect point的2个事情。有个英文的讲解的挺清楚,我也实现了这2个不同的用法,具体看code吧。
VS2008 截图:
Client的运行截图:
运行之后点击 Download,会有个例子,你自己看着改吧。
关键点:

class CUrlDownloadHelper
#if USE_DINTERFACE
: public IDispEventImpl<1, CUrlDownloadHelper, &DIID__IAsyncDownloaderEvents,&LIBID_MYINETUTILSLib>
#else
: public IDispatchImpl<IAsyncDownloaderStartEvents, &IID_IAsyncDownloaderStartEvents, &LIBID_MYINETUTILSLib>,
public CComObjectRoot
#endif
SINK_ENTRY_INFO(1, DIID__IAsyncDownloaderEvents,1,OnStart,&OnStartInfo)
SINK_ENTRY_INFO(1, DIID__IAsyncDownloaderEvents,2,OnData,&OnDataInfo)
SINK_ENTRY_INFO(1, DIID__IAsyncDownloaderEvents,3,OnFinish,&OnFinishInfo)
BEGIN_COM_MAP(CUrlDownloadHelper)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IAsyncDownloaderStartEvents)
END_COM_MAP()
if ( m_lpUrlDld == NULL )
CComObject<CUrlDownloadHelper>::CreateInstance(&m_lpUrlDld);
if ( m_lpUrlDld )
bRet = m_lpUrlDld->InitApis();
C++源代码下载MyInetUtils_src

This entry was posted in 技术开发. Bookmark the permalink.

Comments are closed.