My COM study notes

zhaozj2021-02-17  92

Below this thing is a note when I study COM in 2001. It turned out in Tencent community and was incorporated into the Essence of C / C sector. Recently, I will make COM, make it a little modification, move here in order to find.

=====================================

2001.5.30 1. What is the component? Component is a software module that is specifically used to complete a specific scheduled work, implementing the code multiplexing of the binary stage.

2. What kind of COM? COM, which is Component Object Model (Component Object Model). It is not a programming language, but a set of specifications for constructing binary compatible software components. Software components that can communicate with each other are established in accordance with this specification, regardless of what language or tools are used for these components.

3. Component code: The code for implementing component functions. Interface: It is a set of common functions definitions, which are provided to programs or other components, used to illustrate the functionality of this component, and how to use these functions. GUID (Globally Unique Identifier, globally unique identifier): For a 128-bit integer, used to uniquely identify this component to the operating system and applications. Binary compatibility: Regardless of the language of the component, it is compatible with other COM components and is available for other components.

4. The function should return all methods of the HRESULT COM interface, except for IUNKNOWN: :: AddRef and iunknown :: Release, the return type should be HRESULT, HRESULT is a status code. This status code can be converted into a more detailed scode with getScode ().

5. The implementation of the COM component implementation IUNKNOWN rule memory management rules: Manage memory is the management pointer. Reference counting rules

2001-5-31 1. How to implement a custom interface? Using MIDL (Microsoft Interface Definition Language), it is a REMOTE Procedure Call IDL based on Open Software Foundation Distributed Computing Environment.

2. IDL file import "OAIDL.IDL"; // This file includes the definition of the IDispatch interface, IMPORT is equivalent to #include import "oCIDL.IDL"; [Object, // COM interface definition // ICTADDIN interface unique identifier (GUID) UUID (9edadf6f-c069-11d1-a446-0000e8d2cd0a), DUAL, // indicates that the client can access this interface Helpstring ("ICTADDIN interface"), // Take a prompt string with this interface to connect Pointer_Default (unique) / / Specify the default feature of all pointers other than the properties listed in the parameter table, unique indicates that the pointer can be null, but does not support alias] Interface IctDin: IDispatch {[ID (1), Helpstring ("INSERT Code Template.") ] HRESULT CTInsCodeTmpl ();}; [uuid (9EDADF62-C069-11D1-A446-0000E8D2CD0A), version (1.0), helpstring ( "CodeTmpl Add-in type library")] library CODETMPLLib // type library {importlib ( "stdole32 .tlb "); importlib (" stdole2.tlb "); importlib (" devshl.dll "); importlib (" Ide / devdbg.pkg "); [UUID (9edadf70-c069-11d1-a446-0000e8d2cd0a), Helpstring "CODETMPL - CODE TEMPLATE ADD-IN"] Coclass CTADIN / / Component Class {[Default] interface ictaddin;};}; Establishing a COM server with ATL To create a COM component with ATL, you want to generate classes from at least two classies: ccomobjectroot and ccomcoclass. In addition, you have to deal the CComobject class from your class.

Final finishing: 2003-6-26

转载请注明原文地址:https://www.9cbs.com/read-31508.html

New Post(0)