The TLB file is a description file. Through the TLB file, you can learn the COM interface in your DLL file.
And constant information, so that the user can know the interfaces and constants in your DLL.
You can use your interface. Of course, if your COM interface only needs to be used by yourself, you can not use the TLB file to tell
Other people.
When # import is used to introduce a COM component, it is automatically generated. tlh and. TLI files: These two files are the encapsulation of the COM class. tlh is the standard header file, which defines a smart pointer of the _ com_ptr_t type for each component class, And TLI isCodeFile, which encapsulates the COM component class members. You can import a msado15.dll file by yourself.
TLB often includes the following features:
Intelligent metric announcement: similar scene _ com_ptr_t refers to a smart metric. This case does not mark interface indicators, and CALLS addref and release are excluded, complex steps such as QueryInterface. In addition, it also hides the call for cocreateinstance to create a new COM object. This part uses _ com_smartptr_typedef to generate specialization version of _ com_ptr_t. For example:
_ Com_smartptr_typedef (imyinterface, _ uuidof (imyinterface ));
The compiler will expand the above program
Typedef _ com_ptr_t <_ com_iiid <imyinterface, _ uuidof (imyinterface)> imyinterfaceptr;
As mentioned above, a smart pointer is automatically added when you think about the content in. TLB. cocreateinstance is no longer needed when you create a COM object.
For example, after the library msado15.dll is introduced, the following sentence appears in the msado15.tlh file:
_ Com_smartptr_typedef (_ connection, _ uuidof (_ connection ));
This sentence will be extended by the compiler
Typedef _ com_ptr_t <_ com_iiid <_ connection, 0x0> _ connectionptr
Then you can use this smart pointer _ connectionptr. When creating a COM object
_ Connectionptr pmyconnect = NULL;
Hresult HR = Pmyconnect. createinstance (_ uuidof (connection ));
The connection in _ uuidof (connection) is a struct, which is actually like this
Struct /**/ /*Coclass*/ Connection;
Defined in the msado15.tlh file.
Other types, such as _ recordsetptr and _ commandptr, are of the com_ptr_t type.