A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

destroying Explorer object pointers on shutdown



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 23rd 09, 09:47 PM posted to microsoft.public.outlook.program_addins
Gabriel
external usenet poster
 
Posts: 13
Default destroying Explorer object pointers on shutdown

Another newbie question here. I'm writing an ATL/COM add-in for Outlook 2003.
When quitting Outlook, I was getting an "abnormal program termination" error.
If I understand correctly, this is probably a result of not releasing my
Explorer object pointer? I added a sink for the explorer close event as
recommended but I guess I have to do something other than just set my pointer
to NULL?

(My pointer is: CComPtr Outlook::_Explorer m_spExplorer


Here's my code (checking to see if this is the last :




// gives an "assertion failed" error
void _stdcall CAddin::OnExplorerClose(){

CComPtr Outlook::_Explorers spExplorers;

m_spApp-get_Explorers(&spExplorers);

long count;

spExplorers-get_Count(&count);

if (count == 1){

spExplorerEvents:ispEventUnadvise((IDispatch*)m_ spExplorer);

spExplorerEvents2:ispEventUnadvise((IDispatch*)m _spExplorer);

spExplorerEvents3:ispEventUnadvise((IDispatch*)m _spExplorer);

m_spExplorer = NULL;

}


}

As always, any assistance is greatly appreciated.

-Gabriel
Ads
  #2  
Old April 24th 09, 02:22 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default destroying Explorer object pointers on shutdown

The algorithm is to check in the Close() event for that being the final
Explorer and no Inspectors. Then you have to release all your Outlook object
pointers, not just Explorers. If you have handles to Application, NameSpace,
etc. they all must be released.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Gabriel" wrote in message
...
Another newbie question here. I'm writing an ATL/COM add-in for Outlook
2003.
When quitting Outlook, I was getting an "abnormal program termination"
error.
If I understand correctly, this is probably a result of not releasing my
Explorer object pointer? I added a sink for the explorer close event as
recommended but I guess I have to do something other than just set my
pointer
to NULL?

(My pointer is: CComPtr Outlook::_Explorer m_spExplorer


Here's my code (checking to see if this is the last :




// gives an "assertion failed" error
void _stdcall CAddin::OnExplorerClose(){

CComPtr Outlook::_Explorers spExplorers;

m_spApp-get_Explorers(&spExplorers);

long count;

spExplorers-get_Count(&count);

if (count == 1){

spExplorerEvents:ispEventUnadvise((IDispatch*)m_ spExplorer);

spExplorerEvents2:ispEventUnadvise((IDispatch*)m _spExplorer);

spExplorerEvents3:ispEventUnadvise((IDispatch*)m _spExplorer);

m_spExplorer = NULL;

}


}

As always, any assistance is greatly appreciated.

-Gabriel


  #3  
Old May 4th 09, 08:57 PM posted to microsoft.public.outlook.program_addins
Gabriel
external usenet poster
 
Posts: 13
Default destroying Explorer object pointers on shutdown

Hi Ken,

Thanks for the input. Turns out I'd erroneously added
"m_spExplorer-Close()" to the OnBeginShutdown method when I was first
troubleshooting so I didn't notice one error being replaced by another
similar one (since of course by the time it was called I'd already released
it). Guess it pays to actually read those assertions!

Thanks again,

-Gabriel

"Ken Slovak - [MVP - Outlook]" wrote:

The algorithm is to check in the Close() event for that being the final
Explorer and no Inspectors. Then you have to release all your Outlook object
pointers, not just Explorers. If you have handles to Application, NameSpace,
etc. they all must be released.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access object in explorer from type olExplorer Christian Havel Add-ins for Outlook 3 October 19th 07 06:56 PM
I would NOT install the Desktop Search or Risk Destroying Your Operating System Peter de B. Harrington Outlook - General Queries 5 May 27th 07 07:03 PM
Outlook Application ActiveWindow() always return Explorer object AtulSureka Outlook - Using Forms 3 October 10th 06 02:31 PM
Calendar is Destroying Itself Scott W. Outlook - Calandaring 1 July 13th 06 07:05 AM
Email hyperlinks open Windows Explorer, not Internet Explorer M Skabialka Outlook - General Queries 2 July 7th 06 09:39 PM


All times are GMT +1. The time now is 03:03 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.