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. Releasing a com interface

Releasing a com interface

Scheduled Pinned Locked Moved COM
comtutorialannouncement
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.
  • J Offline
    J Offline
    john5632
    wrote on last edited by
    #1

    Hi Experts, I am using third party com Dll interafces.But sometimes the interfaces return E_OUTOFMEMORY EXCEPTION.So tell me how to release com interface. Thanks

    S E 2 Replies Last reply
    0
    • J john5632

      Hi Experts, I am using third party com Dll interafces.But sometimes the interfaces return E_OUTOFMEMORY EXCEPTION.So tell me how to release com interface. Thanks

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

      The exact mechanism depends on how you're using it. If you're using #import or CComPtr<> smart pointers, then you release the interface by setting the pointer to NULL. If you aren't using smart pointers in this way, you have to call the Release() method. Note that if you copy a pointer without using AddRef() or QueryInterface(), the object may go away unexpectedly. Similarly, if you use AddRef() or QueryInterface() with no corresponding Release(), the object implementing the interface will not necessarily disappear when you expect it to..

      Steve S Developer for hire

      1 Reply Last reply
      0
      • J john5632

        Hi Experts, I am using third party com Dll interafces.But sometimes the interfaces return E_OUTOFMEMORY EXCEPTION.So tell me how to release com interface. Thanks

        E Offline
        E Offline
        Erik Midtskogen
        wrote on last edited by
        #3

        What language are you coding in? In VB, just make sure you set all of the objects you create to Nothing as soon as you're done with them: Set MyLibraryInterface = Nothing Set MyBusinessObject = Nothing In many situations, you don't really need to do this unless you're creating a lot of objects that don't fall out of scope right away In C++, you just call ->Release() on your interface pointer. MyComObject* pMyComObject = NULL; (send the pointer into your class factory CreateInstance call here) (do your business logic here) pMyComObject->Release(); // All done Hope this helps.

        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