PC Review


Reply
Thread Tools Rate Thread

Accessing Application.Explorers.Count property calls Release() ??

 
 
Eric
Guest
Posts: n/a
 
      14th Oct 2003
I'm writing an Outlook COM Add-in using C++. During the
OnStartupComplete event I get the Application.Explorers object, which
I am able to work with for the most part. I can setup event sinks for
it, etc.

The problem comes up when I check the "Count" property of the
Explorers object. It seems like an IUnknown::Release() call is also
being made. I wrote some quick code to check this, like:

before = Explorers->AddRef();
c = Explorers->GetCount();
after = Explorers->Release();

The call to AddRef() before I access the Count property returns 3. I
would then expect the Release() call to return 2, however it doesn't,
it returns 1.

Is this expected? If so, how do I know if accessing a property is
going to have this affect, is there a list somewhere?

On another note, are there any good books on writing an Outlook COM
Add-in using just C++ without MFC/ATL/etc? I'm doing pretty good so
far, but I'm worried about memory leaks due to these AddRef() and
Release() calls. I'm doing things at a very low level, without
importing type libraries or anything, just working at the IDispatch
level for everything. For me this seems easier, but I must be the
only one going this route, because I'm having trouble finding any
examples. Even the "C++ without MFC/ATL" MSGDUMP2000 example imports
the type libraries. I have no urge to work with those huge header
files or have to deal with differences of how each compiler builds a
type library header.
 
Reply With Quote
 
 
 
 
Eric
Guest
Posts: n/a
 
      14th Oct 2003
I figured it out myself, just a bone-head move. I wasn't clearing the
VARIANT type variable before using it again, so somewhere inside the
OLE or Outlook code it must have been clearing it for me, which
explains the Release() call on the object.

(E-Mail Removed) (Eric) wrote in message news:<(E-Mail Removed)>...
> I'm writing an Outlook COM Add-in using C++. During the
> OnStartupComplete event I get the Application.Explorers object, which
> I am able to work with for the most part. I can setup event sinks for
> it, etc.
>
> The problem comes up when I check the "Count" property of the
> Explorers object. It seems like an IUnknown::Release() call is also
> being made. I wrote some quick code to check this, like:
>
> before = Explorers->AddRef();
> c = Explorers->GetCount();
> after = Explorers->Release();
>
> The call to AddRef() before I access the Count property returns 3. I
> would then expect the Release() call to return 2, however it doesn't,
> it returns 1.
>
> Is this expected? If so, how do I know if accessing a property is
> going to have this affect, is there a list somewhere?
>
> On another note, are there any good books on writing an Outlook COM
> Add-in using just C++ without MFC/ATL/etc? I'm doing pretty good so
> far, but I'm worried about memory leaks due to these AddRef() and
> Release() calls. I'm doing things at a very low level, without
> importing type libraries or anything, just working at the IDispatch
> level for everything. For me this seems easier, but I must be the
> only one going this route, because I'm having trouble finding any
> examples. Even the "C++ without MFC/ATL" MSGDUMP2000 example imports
> the type libraries. I have no urge to work with those huge header
> files or have to deal with differences of how each compiler builds a
> type library header.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DeploymentException when accessing Application.UserAppDataPath property cody Microsoft VB .NET 0 21st Aug 2007 10:35 PM
Setting property value to string or accessing property methods Brian Mitchell Microsoft VB .NET 2 26th May 2005 01:27 PM
System explorers and application agents not working director59 Spyware Application Compatibility 2 16th Apr 2005 11:54 PM
Property Value Changes Value between calls =?Utf-8?B?cG9seW5vbWlhbDVk?= Microsoft ADO .NET 1 4th Feb 2004 08:11 AM
Accessing Count property calls Release() Eric Microsoft Outlook Program Addins 1 14th Oct 2003 09:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:14 PM.