ATL

Normal COM.cpp

 1 #include "resource.h"       // 主符号
 2 #include "ATLCOM_i.h"
 3 #include "_IDragonComEvents_CP.h"
 4 #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
 5 #error "Windows CE 平台(如不提供完全 DCOM 支持的 Windows Mobile 平台)上无法正确支持单线程 COM 对象。定义 _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA 可强制 ATL 支持创建单线程 COM 对象实现并允许使用其单线程 COM 对象实现。rgs 文件中的线程模型已被设置为“Free”,原因是该模型是非 DCOM Windows CE 平台支持的唯一线程模型。"
 6 #endif
 7 
 8 using namespace ATL;
 9 // CDragonCom
10 class ATL_NO_VTABLE CDragonCom :
11     public CComObjectRootEx<CComMultiThreadModel>,
12     public CComCoClass<CDragonCom, &CLSID_DragonCom>,
13     public ISupportErrorInfo,
14     public IConnectionPointContainerImpl<CDragonCom>,
15     public CProxy_IDragonComEvents<CDragonCom>,
16     public IObjectWithSiteImpl<CDragonCom>,
17     public IDispatchImpl<IDragonCom, &IID_IDragonCom, &LIBID_ATLCOMLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
18 {
19 public:
20     CDragonCom()
21     {
22     }
23 
24 DECLARE_REGISTRY_RESOURCEID(IDR_DRAGONCOM)
25 BEGIN_COM_MAP(CDragonCom)
26     COM_INTERFACE_ENTRY(IDragonCom)
27     COM_INTERFACE_ENTRY(IDispatch)
28     COM_INTERFACE_ENTRY(ISupportErrorInfo)
29     COM_INTERFACE_ENTRY(IConnectionPointContainer)
30     COM_INTERFACE_ENTRY(IObjectWithSite)
31 END_COM_MAP()
32 
33 BEGIN_CONNECTION_POINT_MAP(CDragonCom)
34     CONNECTION_POINT_ENTRY(__uuidof(_IDragonComEvents))
35 END_CONNECTION_POINT_MAP()
36 // ISupportsErrorInfo
37     STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
38     DECLARE_PROTECT_FINAL_CONSTRUCT()
39     HRESULT FinalConstruct()
40     {
41         return S_OK;
42     }
43     void FinalRelease()
44     {
45     }
46 
47 public:
48 //Add myself code here
49 protected:
50     int iAcountNo;
51 public:
52     void SetAccountNo(void);
53 };
54 OBJECT_ENTRY_AUTO(__uuidof(DragonCom), CDragonCom)

 

  • IDispatch

 

  • IPersist

  • ICollection & IEnum

  • IConnection

 

  • SmartPtr

  • Module

  • COMRoot

  • CComCoClass

  • ATL-Layer

 

 

posted @ 2013-08-15 08:35  iDragon  阅读(378)  评论(0编辑  收藏  举报