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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.