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. Where I have to call CoUnInitialize function if I have COM interfaces in (MFC) application main class?

Where I have to call CoUnInitialize function if I have COM interfaces in (MFC) application main class?

Scheduled Pinned Locked Moved COM
c++comhelpquestionannouncement
5 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.
  • R Offline
    R Offline
    Rula Ghabbiesh
    wrote on last edited by
    #1

    I couldn't call CoUnInitialize function in ExitInstance or in class destructor(there will be crash), since I have COM interfaces (member variables)in application main class,(They are smart pointers),so a calling to COM interfaces release function will make the problem.

    S M 2 Replies Last reply
    0
    • R Rula Ghabbiesh

      I couldn't call CoUnInitialize function in ExitInstance or in class destructor(there will be crash), since I have COM interfaces (member variables)in application main class,(They are smart pointers),so a calling to COM interfaces release function will make the problem.

      S Offline
      S Offline
      Shadi Al Kahwaji
      wrote on last edited by
      #2

      Hi, If you are using Document/View Architecture, you can put your smart pointers as member variavles in the Document class. At that time you can call CoUnitialize() either in the Main App Destructor or in App ExitInsnance :). ShadiK Shadi Al-Kahwaji

      1 Reply Last reply
      0
      • R Rula Ghabbiesh

        I couldn't call CoUnInitialize function in ExitInstance or in class destructor(there will be crash), since I have COM interfaces (member variables)in application main class,(They are smart pointers),so a calling to COM interfaces release function will make the problem.

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

        You don't have to. You call AfxOleInit() in your app's InitInstance() and that's it. MFC handles uninitializing COM when you app closes. --Mike-- http://home.inreach.com/mdunn/ "The Earth is doomed." -- Rupert Giles :love: your :bob: with :vegemite: and :beer:

        R 1 Reply Last reply
        0
        • M Michael Dunn

          You don't have to. You call AfxOleInit() in your app's InitInstance() and that's it. MFC handles uninitializing COM when you app closes. --Mike-- http://home.inreach.com/mdunn/ "The Earth is doomed." -- Rupert Giles :love: your :bob: with :vegemite: and :beer:

          R Offline
          R Offline
          Rula Ghabbiesh
          wrote on last edited by
          #4

          It doesn't solve my problem. The same crash will happen when the application releases smart pointers members.:)

          M 1 Reply Last reply
          0
          • R Rula Ghabbiesh

            It doesn't solve my problem. The same crash will happen when the application releases smart pointers members.:)

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

            Then call their Release() methods in your ExitInstance(). --Mike-- http://home.inreach.com/mdunn/ "The Earth is doomed." -- Rupert Giles :love: your :bob: with :vegemite: and :beer:

            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