What event does IE send when the activex control is unloaded?

Hi, I have ActiveX like this:

  class CMyActiveX:
    public CComObjectRootEx ...
    ...
 {
    HRESULT FinalContruct () {return S_OK;}
    void Start ()
    {
       // a new thread is created here for some task
    }
    void FinalRelease ()
    {
       // if the thread is alive kill it
    }
 }

However, when the browser is closed, the FinalRelease method is not called. Thus, the stream is saved, and a failure occurs at the output.

Any idea on this? Thanks!

+4
source share
1 answer

I found that my :: SetClientSite (NULL) control was reliably called by IE when closing or exiting the page, so I do my important things there. This is a method override in IOleObjectImpl.

HRESULT CControl::SetClientSite(IOleClientSite *pClientSite) { if (!pClientSite) { // Means IE is closing or about to, or at least // that we've lost our place in the sun... do shutdown stuff } IOleObjectImpl::SetClientSite(pClientSite); if (pClientSite) { .... 

MSDN Method - IOleObject :: SetClientSite

+1
source

Source: https://habr.com/ru/post/1311043/


All Articles