com开发内容摘要:
if (m_pOuterUnknown != NULL) return m_pOuterUnknownAddRef()。 return InternalAddRef()。 } DWORD CCmdTarget::ExternalRelease() // … ... // QueryInterface that is exported to normal clients DWORD CCmdTarget::ExternalQueryInterface(const void* iid, LPVOID* ppvObj) { // delegate to controlling unknown if aggregated if (m_pOuterUnknown != NULL) return m_pOuterUnknownQueryInterface(*(IID*)iid, ppvObj)。 return InternalQueryInterface(iid, ppvObj)。 } 嵌套类内部实现 IUnknown的成员函数 STDMETHODIMP_(ULONG) CDictionary::XDictionary::QueryInterface ( const void* iid, LPVOID* ppvObj) { METHOD_PROLOGUE_EX_(CDictionary, Dictionary) return pThisExternalQueryInterface (iid, ppvObj)。 } COM引出函数和类厂实现 在 AppWizard中选中 “ Automation”检查框 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { AFX_MANAGE_STATE(AfxGetStaticModuleState())。 return AfxDllGetClassObject(rclsid, riid, ppv)。 } STDAPI DllCanUnloadNow(void) { AFX_MANAGE_STATE(AfxGetStaticModuleState())。 return AfxDllCanUnloadNow()。 } // by exporting DllRegisterServer, you can use STDAPI DllRegisterServer(void) { AFX_MANAGE_STATE(AfxGetStaticModuleState())。 COleObjectFactory::UpdateRegistryAll()。 return S_OK。 } COleObjectFactory 通用的类厂,实现了 IClassFactory2接口 COleObjectFactory的主要信息是对象的 CLSID和对象的类型信息。 它利用 MFC的动态对象创建机制: – DECLARE_DYNCREATE 对象方面的支持: – DECLARE_OLECREATE(...),定义如下 define DECLARE_OLECREATE(class_name) \ public: \ static AFX_DATA COleObjectFactory factory。 \ static AFX_DATA const GUID guid。 \ MFC中组件对象的创建支持 DECLARE_OLECREATE(...) IMPLEMENT_OLECREATE define IMPLEMENT_OLECREATE(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ AFX_DATADEF COleObjectFactory class_name::factory(class_name::guid, \ RUNTIME_CLASS(class_name), FALSE, _T(external_name))。 \ AFX_COMDAT const AFX_DATADEF GUID class_name::guid = \ { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }。 \ 状态结构: AFX_MODULE_STATE,除了一些基本的全局信息,还包括一个类厂表。 DllGetClassObject〉 AfxDllGetClassObject〉AfxGetModuleState进一步得到类厂表 类厂对象的构造函数和析构函数维护类厂表 用 MFC开发 COM应用 利用 AppWizard创建 COM程序工程框架 利用 ClassWizard添加 COM对象类 AppWizard创建 COM工程 (一 ) AppWizard创建 COM工程 (二 ) AppWizard创建 COM工程 (三 ) BOOL CDictCompApp::InitInstance() { // Register all OLE server (factories) as running. // This enables the // OLE libraries to create objects from other applications. COleObjectFactory::RegisterAll()。 return TRUE。 } ClassWizard添加 COM对象类 (一 ) ClassWizard添加 COM对象类 (二 ) CDictionaryObj声明中加入接口定义 BEGIN_INTERFACE_PART(Dictionary, IDictionary) INIT_INTERFACE_PART(CDictionary, Dictionary) STDMETHOD_(BOOL, Initialize)()。 STDMETHOD_(BOOL, LoadLibrary)(LPOLESTR)。 STDMETHOD_(BOOL, InsertWord)(LPOLESTR, LPOLESTR)。 STDMETHOD_(void, DeleteWord)( LPOLESTR)。 STDMETHOD_(BOOL, LookupWord)(LPOLESTR, LPOLESTR *)。 STDMETHOD_(BOOL, RestoreLibrary)(LPOLESTR)。 STDMETHOD_(void, FreeLibrary)()。 END_INTERFACE_PART_STATIC(Dictionary) // ISpellCheck BEGIN_INTERFACE_PART(SpellCheck, ISpellCheck) INIT_INTERFACE_PART(CDictionary, SpellCheck) STDMETHOD_(BOOL, CheckWord)(LPOLESTR, LPOLESTR *)。 END_INTERFACE_PART_STATIC(SpellCheck) DECLARE_INTERFACE_MAP() CDictionaryObj类实现文件中 加入相应的定义 extern C const IID IID_Dictionary = { 0x54bf6568, 0x1007, 0x11d1, { 0xb0, 0xaa, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} }。 extern C const IID IID_SpellCheck = { 0x54bf6569, 0x1007, 0x11d1, { 0xb0, 0xaa, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} }。 BEGIN_INTERFACE_MAP(CDictionaryObj, CCmdTarget) INTERFACE_PART(CDictionaryObj, IID_IDictionary, Dictionary) INTERFACE_PART(CDictionaryObj, IID_ISpellCheck, SpellCheck) END_INTERFACE_MAP() 类厂支持 在 CDictionaryObj声明中加入: DECLARE_OLECREATE(CDictionaryObj) 在 CDictionaryObj实现文件中加入: // {54BF6567100711D1B0AA444553540000} IMPLEMENT_OLECREATE(CDictionaryObj, , 0x54bf6567, 0x1007, 0x11d1, 0xb0, 0xaa, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00) ATL介绍 ATL实现 COM的机制完全不同于 MFC 使用多继承技术实现多个接口 支持多线程 实现 QueryInterface用到了特殊的技术 创建对象机制不同于以往的技术 优化 ATL概况 封装了一些数据类型 – CComBSTR、 CComVariant、 CComPtr,等 实现 COM接口和 COM对象 – 接口映射表、对象映射表,等 窗口的支持 – CWindow、 CWindowImpl、 CDialogImpl,等 其他 COM特征的支持 – 永久性支持 – 连接点支持 – 集合对象和枚举器对象 – ActiveX control and container – 等 CComBSTR 封装了 BSTR类型 提供了大量便利的字符串操作 –构造函数 –各种操作符以及一般的字符串操作 –对于流 (stream)的支持 在需要 BSTR的地方,都可以用CComBSTR来代替 注意 owership CComVariant 封装了 VARIANT属性 提供了常用的操作 –构造函数 –各种操作符以及一般的管理操作 –对于流 (stream)的支持 在需要 VARIANT的地方,都可以用CComVARIANT来。com开发
相关推荐
记语言,其采用纯文本格式,具有很好的交换性,使其成为开展以内容为核心的 元数据应用的首选描述语言 DTD: Document Type Definition XML Schema 支持多种数据类型 XML:资源交换格式 • RDF的数据模型可以用有向图描述: – Ora Lassila is the creator of the resource – 三元组( S( Subject)
erface SOAP libraries (stub code) can be generated automatically from WSDLs Custom Client holdJob() SOAP library Submission machine(s) Schedd 7 Example: Query Collector Obtain information
orming to recognised standards, with a clear scope of high data rates such as HIPERLAN/2, , and so on doc.: IEEE Submission May 2020 Vic Hayes, Lucent Technologies Slide 9 Remendation 2 • Add
标准 • 通常是 NPHard • 多项式算法 并非精确的最优解,而是相对优的解或者局部的最优解 算法一 • 判断标准: kcenter criterion 最小化任意点到所分的类中心的最大距离 • 基本思想: 存在 k个半径为 r的球体覆盖所有点 存在最大距离为 r的划分 算法一 • 步骤 每次选取一个未被覆盖的 数据 点作为一个类的中心,作半径为 r的球体,覆盖某些点。 重复 k次得到
tories about how film has developed from the earlier years to recent years will be shared。 while through the readings and exercises, students will be able to: – Read films as both narrative and
its, the candidate kdimensional units are determined using candidate generation procedure. MDLbased pruning To decide which subspaces(and the corresponding dense units) are interesting.