The destructor or my Active Directory's extended property sheet(COM) is not being invokedd at time of exit.

Hi Expert,
I'm wroking on a COM in-proc server using C++ in VS 2005 using only the win libraries.  This is to create 3 extended property pages in Active Directory.  I have a base class, CpropertyPage, which is from MS SDK for mmc's ppgext.cpp.  My property pages are display as one of the tab in AD's Computer, Users and Groups property window.  

The question I have is, how can I get my property sheet's destructor be called or invoked (actually I think mmc does this).  I know my base class CpropertyPage's destructor is being called when I click OK button to exit the property window.  I have to do some memory clean up in my own destructor and thus need each of my property sheet's destructor to be called.  

Thank you.
Who is Participating?
Actually, the destructor will be called by your 'Release()' method when the reference counter drops to zero, e.g.

ULONG MyComObj::Release() {

    if (!--m_ulRefCnt) {

        delete this; // destroy object, invoke MyComObj::~MyComObj()

    return m_ulRefCnt;
lapuccaAuthor Commented:
Thank you expert jkr,

The standard COM interface are implemented in the base class CPropertyShee and it's Release method is invoked but it only calls it's destructor and its child class, my AD extended property sheets' destructor was never invoked.  
I tried calling my own destructor today at the DialogProc method but it casued an Assertion Error and crashed the appl.  

Should I (and can I ) add a Release mehtod in the child property sheets module to do this?  

lapuccaAuthor Commented:
To sovle this problem I had to virtual the destructor of the base class.  The child desctor of my property sheet is then invoked.  thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.