Outlook 2007: Problem with SinkEvents on first explorer

  • Thread starter news.microsoft.com
  • Start date
N

news.microsoft.com

Hi,

I'm having trouble sinking events on the initial Outlook explorer with the OL 2007 Beta.

I get an exception (access violation) on this queryinterface call in my explorer event handler when I try to sink events.

hr = m_pExplorer->QueryInterface(IID_IConnectionPointContainer, (void **)&pCPC);

m_pExplorer is an Outlook::_ExplorerPtr

Here's the code in context .....
void CExplorerHandler::SinkEvents()
{
HRESULT hr;

IConnectionPointContainer* pCPC;
hr = m_pExplorer->QueryInterface(IID_IConnectionPointContainer, (void **)&pCPC);
if (SUCCEEDED(hr))
{
hr = pCPC->FindConnectionPoint(__uuidof(Outlook::ExplorerEvents), &m_pConnection);
if (SUCCEEDED(hr))
{
AddRef();

hr = m_pConnection->Advise(static_cast<IDispatch*>(this), &m_dwCookie);
}

<----- SNIP ---->
Now this used to work just fine on OL2003 (and OLXP and OL2000) and also works on any additional explorers opened in Outlook 2007.

It just seems to be the 1st one that causes the problem.

Any ideas ? ....... A security issue ? A Microsoft bug ? Something about the timing of the Outlook startup has changed ?

Regards,

Scott Quinn
 
D

Dmitry Streblechenko

An obvious question: are you sure m_pExplorer is not NULL?
When do you make that call?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hi,

I'm having trouble sinking events on the initial Outlook explorer with the
OL 2007 Beta.

I get an exception (access violation) on this queryinterface call in my
explorer event handler when I try to sink events.

hr = m_pExplorer->QueryInterface(IID_IConnectionPointContainer, (void
**)&pCPC);

m_pExplorer is an Outlook::_ExplorerPtr

Here's the code in context .....
void CExplorerHandler::SinkEvents()
{
HRESULT hr;

IConnectionPointContainer* pCPC;
hr = m_pExplorer->QueryInterface(IID_IConnectionPointContainer, (void
**)&pCPC);
if (SUCCEEDED(hr))
{
hr = pCPC->FindConnectionPoint(__uuidof(Outlook::ExplorerEvents),
&m_pConnection);
if (SUCCEEDED(hr))
{
AddRef();

hr = m_pConnection->Advise(static_cast<IDispatch*>(this),
&m_dwCookie);
}

<----- SNIP ---->
Now this used to work just fine on OL2003 (and OLXP and OL2000) and also
works on any additional explorers opened in Outlook 2007.

It just seems to be the 1st one that causes the problem.

Any ideas ? ....... A security issue ? A Microsoft bug ? Something about the
timing of the Outlook startup has changed ?

Regards,

Scott Quinn
 
S

Scott Quinn

Hi Dmitry,

No .... the pointer is not NULL.

I get the pointer from the app by calling ActiveExplorer (and I get the same
pointer getting the first item from the explorers collection).

The call itself is initially made in raw_OnStartupComplete (while at the
same time I successfully sink events on the explorers and inspectors
collections).

The application continues to try sink events on the main explorer itself
later (called by a timer).... but still without any luck..

Scott
 
S

Scott Quinn

Good point Dmitry and yeah they were exception fodder too.

Anyway I have a solution.....

While the pointer from ActiveExplorer() appears to be a valid pointer and
some methods seem work (AddRef) for the most part it's stuffed.

If I get a pointer from the explorers collection all works fine.

So there may be a bug in OL2007 with the object model and ActiveExplorer()

Thanks,

Scott Quinn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top