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. ATL / WTL / STL
  4. Creating instances of COM objects inside the module

Creating instances of COM objects inside the module

Scheduled Pinned Locked Moved ATL / WTL / STL
c++comquestionworkspace
3 Posts 2 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.
  • J Offline
    J Offline
    jparsons
    wrote on last edited by
    #1

    I have an ATL project where I define several ATL COM objects. I would like to be able to create instances of these objects inside my module without having to use CoCreateInstance(). Everytime I try to do so it claims the classes are abstract because they do not define QueryInterface,AddRef... Is there a way to create these objects internally without having to call CoCreateInstance? Here's the logic to why I want to do this. I'm using a local class to catch some COM events. The local class implements a COM interface but itself is not a COM object. If I create this class with CoCreateInstance I will only be able to get the Event Sink interface back. The only way that I know of to call methods on this object would be to create a new interface for the object for the local methods I need. I would really like to avoid this. Here is a sample bit of code to show better what I'm trying to do CEventSink : public _IEvents { public: void Setup(IEventSource *source); } ... CEventSink sink; IEventSource *source; ... CoCreatInstance for source... sink.Setup(source); Jared jparsons@jparsons.org www.prism.gatech.edu/~gte477n

    M 1 Reply Last reply
    0
    • J jparsons

      I have an ATL project where I define several ATL COM objects. I would like to be able to create instances of these objects inside my module without having to use CoCreateInstance(). Everytime I try to do so it claims the classes are abstract because they do not define QueryInterface,AddRef... Is there a way to create these objects internally without having to call CoCreateInstance? Here's the logic to why I want to do this. I'm using a local class to catch some COM events. The local class implements a COM interface but itself is not a COM object. If I create this class with CoCreateInstance I will only be able to get the Event Sink interface back. The only way that I know of to call methods on this object would be to create a new interface for the object for the local methods I need. I would really like to avoid this. Here is a sample bit of code to show better what I'm trying to do CEventSink : public _IEvents { public: void Setup(IEventSource *source); } ... CEventSink sink; IEventSource *source; ... CoCreatInstance for source... sink.Setup(source); Jared jparsons@jparsons.org www.prism.gatech.edu/~gte477n

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

      Q181265: HOWTO: Create ATL COM Objects[^] --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released

      J 1 Reply Last reply
      0
      • M Michael Dunn

        Q181265: HOWTO: Create ATL COM Objects[^] --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released

        J Offline
        J Offline
        jparsons
        wrote on last edited by
        #3

        Thanks. That was exactly what i was looking for. Jared jparsons@jparsons.org www.prism.gatech.edu/~gte477n

        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