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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. queryInterface

queryInterface

Scheduled Pinned Locked Moved COM
question
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.
  • W Offline
    W Offline
    waliop
    wrote on last edited by
    #1

    wt actually working of queryinterface function? sdfsdfsdfhsdfh

    S B 2 Replies Last reply
    0
    • W waliop

      wt actually working of queryinterface function? sdfsdfsdfhsdfh

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      QueryInterface is a discovery mechanism. Let's say you have an interface (any interface, it doesn't matter) to a COM component. You can, using a method in the interface, ask the component if it supports another interface that you know about. For instance, you might have an IFrooble interface on an object, and you want to know if it supports automation using the 'classic IDispatch' method. You say something like: HRESULT hr; IDispatch* pDisp = NULL; hr = pFrooble->QueryInterface( IID_IDispatch, reinterpret_cast<void**>(&pDisp)); if (SUCCEEDED(hr)) { // Yep, it does dispatch, and we now have that interface as well // as the IFrooble one. } else { // No, it doesn't or can't provide that interface } Does that help? Another scenario is versioned interfaces, where a client will ask for successive interfaces (eg IFooBar4, IFooBar3, IFooBar2, IFooBar) until it gets one it's happy with. Steve S

      1 Reply Last reply
      0
      • W waliop

        wt actually working of queryinterface function? sdfsdfsdfhsdfh

        B Offline
        B Offline
        Big_M
        wrote on last edited by
        #3

        If you look from the C++ point of view, All you interfaces to COM object are abstract base classes with pure virtual functions. And your COM object gives implementation of all these functions. So when you call QueryInterface, it simple casts the COM object(this) into the interface pointer, increase a reference count and return that pointer. This way you can only call the functions declared in that interface.

        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