Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. using interface

using interface

Scheduled Pinned Locked Moved COM
comquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chiman1
    wrote on last edited by
    #1

    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?

    J _ 2 Replies Last reply
    0
    • C Chiman1

      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?

      J Offline
      J Offline
      Jonathan Davies
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • C Chiman1

        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?

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        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 of xxxPtr 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 like CoCreateInstance 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++)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups