visual-c++comstaticobject-destruction

Static CComPtr Variable


Is it bad idea to have static CComPtr member variables in an application. Since we cannt control destruction of static variable and it can happen after CoUninitialze .


Solution

  • Provided you take the appropriate precautions, then using a CComPtr as a static member is not inherently evil.

    By "appropriate precautions", I mean you should consider: