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

Posted on 2006-04-19
Last Modified: 2013-12-03
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.
Question by:lapucca
    LVL 86

    Accepted Solution

    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;

    Author Comment

    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?  


    Author Comment

    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.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
    This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now