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. Q: how to expose an interface using ATL?

Q: how to expose an interface using ATL?

Scheduled Pinned Locked Moved COM
c++helpquestioncomtutorial
2 Posts 2 Posters 4 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.
  • T Offline
    T Offline
    Tony Young
    wrote on last edited by
    #1

    Hi, In MFC, people can derive a class (say CA) from CCmdTarget, and then use macros such as BEGIN_DUAL_INTERFACE_PART, BEGIN_INTERFACE_MAP etc. to expose an interface. Another dll can access this interface by instantiating CA and then call CA's GetInterface(). My question is how to achieve the same thing using ATL? I tried to create a ATL project with a COM class exposing a dual interface. If I instantiate the COM class, I would get a compile error saying virtual functions AddRef, Release,QueryInterface are not implemented. I don't need proxy/stub code involved becuase this interface is accessed not through COM actually. The reason I have to do this because another DLL requires my DLL's exported class to expose a dual interface for it. Thanks in advance for your big help and precious time. Tony

    M 1 Reply Last reply
    0
    • T Tony Young

      Hi, In MFC, people can derive a class (say CA) from CCmdTarget, and then use macros such as BEGIN_DUAL_INTERFACE_PART, BEGIN_INTERFACE_MAP etc. to expose an interface. Another dll can access this interface by instantiating CA and then call CA's GetInterface(). My question is how to achieve the same thing using ATL? I tried to create a ATL project with a COM class exposing a dual interface. If I instantiate the COM class, I would get a compile error saying virtual functions AddRef, Release,QueryInterface are not implemented. I don't need proxy/stub code involved becuase this interface is accessed not through COM actually. The reason I have to do this because another DLL requires my DLL's exported class to expose a dual interface for it. Thanks in advance for your big help and precious time. Tony

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      In ATL, your CA class is an abstract base class - it doesn't have implementations of the IUnknown methods, as you've found out from the compiler errors. See KB article Q181265 for the steps you take to make a new object. Basically, you instantiate a CComObject<CA> instead - CComObject provides the IUnknown implementation. --Mike-- http://home.inreach.com/mdunn/ "That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."   --Buffy

      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