using interface
-
I want to use an interface method in my com class . Now this can be archive by two ways 1) by importing tlb file in idl file. ii) by including/adding .h file. Can you please explain the diff betn approach i and ii and in which scenario we should use them?
-
I want to use an interface method in my com class . Now this can be archive by two ways 1) by importing tlb file in idl file. ii) by including/adding .h file. Can you please explain the diff betn approach i and ii and in which scenario we should use them?
Reading from my COM IDL & Interface Design by Al Major (Wrox): #include The contents of the #included file are placed in the idl as if they had been typed in. import Is the standard method for bringing in definitions from other idl, odl or C/C++ header files into the main IDL file Al recommends: not using #include unless you need to support legacy types and using: import to get at IDL declarations.
-
I want to use an interface method in my com class . Now this can be archive by two ways 1) by importing tlb file in idl file. ii) by including/adding .h file. Can you please explain the diff betn approach i and ii and in which scenario we should use them?
Importing using
#import
can be used to instantiate a COM component from its type library that is either embedded inside the DLL or as a separate file (.TLB file). This method prompts the compiler to create the header files which is automatically included in the generated source codes. It also create smart pointer for all the exposed interfaces using the_com_ptr_t
class. The smart pointers will have a naming convention ofxxxPtr
where xxx is the name of the exposed interface. The method of#include
is a more basic approach where you use the standard COM APIs likeCoCreateInstance
to instantiate and use the COM component. You will have to manually create smart pointers if needed.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)