PC Review


Reply
Thread Tools Rate Thread

Access Violation when closing Send To window

 
 
Matt Fletcher
Guest
Posts: n/a
 
      20th Jan 2004
I'm trying to prevent my add-in causing an access violation in MSMAPI32 at
3552fe50. This occurs when an Outlook Window which was generated from Send
To->Mail Recipient (on an explorer/desktop context menu) is closed. The
problem occurs in Windows 2000 and Windows 98, but not in Windows XP.

The trap appears to be caused by sinking ItemEvents from a MailItemPtr which
is itself derived from the Inspector associated with a "Send To" Outlook
window.

I have reproduced this problem using a test add-in: all it does is start a
thread which sits in a loop waiting for an Application::Inspector to give me
an InspectorPtr - when it does I call GetCurrentItem and sink the events.
Sample code below - stripped of error handling and tracing for brevity. (I
realise this is an unsophisticated way to get hold of the MailItem, but it
gets round the lack of a NewInspector event).

Any help with this particular brick wall greatly appreciated!

Matt Fletcher


STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
AddInDesignerObjects::ext_ConnectMode
ConnectMode,
IDispatch *pAddInInst,
SAFEARRAY ** /*custom*/ )
{
m_spOutlookApplication = (_ApplicationPtr)pApplication;
return S_OK;
}

STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
{
DWORD dwID;
::CreateThread(NULL, 0, SendToHandlerProc, (LPVOID)this, 0, &dwID);
return S_OK;
}

void CConnect::AttachToMessage()
{
if (!m_bAttached)
{
_InspectorPtr spInspector =
m_spOutlookApplication->ActiveInspector();
if (spInspector)
{
m_spMailItem = spInspector->GetCurrentItem();
if (m_spMailItem)
{
MailItemEventsImpl:ispEventAdvise(m_spMailItem);
m_bAttached = true;
}
}
}
}

DWORD WINAPI CConnect::SendToHandlerProc(LPVOID lpParameter)
{
CConnect * pConnect = (CConnect *)lpParameter;
while (!m_bAttached)
{
pConnect->AttachToMessage();
::Sleep(500);
}

return 0;
}

STDMETHODIMP_(void) CConnect::OnItemClose(VARIANT_BOOL * Cancel)
{
MessageBox(NULL, "OnItemClose", "Debug", MB_OK);

if (m_spMailItem)
MailItemEventsImpl:ispEventUnadvise(m_spMailItem);

m_spMailItem = 0;
m_spOutlookApplication = 0;
}


 
Reply With Quote
 
 
 
 
Thomas Wetzel
Guest
Posts: n/a
 
      21st Jan 2004
Hello Matt,

what Outlook version?

Thomas Wetzel

"Matt Fletcher" <(E-Mail Removed)> wrote in message
news:bujj00$249$(E-Mail Removed)...
> I'm trying to prevent my add-in causing an access violation in MSMAPI32 at
> 3552fe50. This occurs when an Outlook Window which was generated from Send
> To->Mail Recipient (on an explorer/desktop context menu) is closed. The
> problem occurs in Windows 2000 and Windows 98, but not in Windows XP.
>
> The trap appears to be caused by sinking ItemEvents from a MailItemPtr

which
> is itself derived from the Inspector associated with a "Send To" Outlook
> window.
>
> I have reproduced this problem using a test add-in: all it does is start a
> thread which sits in a loop waiting for an Application::Inspector to give

me
> an InspectorPtr - when it does I call GetCurrentItem and sink the events.
> Sample code below - stripped of error handling and tracing for brevity. (I
> realise this is an unsophisticated way to get hold of the MailItem, but it
> gets round the lack of a NewInspector event).
>
> Any help with this particular brick wall greatly appreciated!
>
> Matt Fletcher
>
>
> STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
> AddInDesignerObjects::ext_ConnectMode
> ConnectMode,
> IDispatch *pAddInInst,
> SAFEARRAY ** /*custom*/ )
> {
> m_spOutlookApplication = (_ApplicationPtr)pApplication;
> return S_OK;
> }
>
> STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
> {
> DWORD dwID;
> ::CreateThread(NULL, 0, SendToHandlerProc, (LPVOID)this, 0, &dwID);
> return S_OK;
> }
>
> void CConnect::AttachToMessage()
> {
> if (!m_bAttached)
> {
> _InspectorPtr spInspector =
> m_spOutlookApplication->ActiveInspector();
> if (spInspector)
> {
> m_spMailItem = spInspector->GetCurrentItem();
> if (m_spMailItem)
> {
> MailItemEventsImpl:ispEventAdvise(m_spMailItem);
> m_bAttached = true;
> }
> }
> }
> }
>
> DWORD WINAPI CConnect::SendToHandlerProc(LPVOID lpParameter)
> {
> CConnect * pConnect = (CConnect *)lpParameter;
> while (!m_bAttached)
> {
> pConnect->AttachToMessage();
> ::Sleep(500);
> }
>
> return 0;
> }
>
> STDMETHODIMP_(void) CConnect::OnItemClose(VARIANT_BOOL * Cancel)
> {
> MessageBox(NULL, "OnItemClose", "Debug", MB_OK);
>
> if (m_spMailItem)
> MailItemEventsImpl:ispEventUnadvise(m_spMailItem);
>
> m_spMailItem = 0;
> m_spOutlookApplication = 0;
> }
>
>



 
Reply With Quote
 
Matt Fletcher
Guest
Posts: n/a
 
      22nd Jan 2004
I've reproduced the problem using Outlook XP (build 10.4219.4219) on Windows
2000 and Outlook 2000 (build 9.0.0.3821) on Windows 98 (in a Virtual
Machine). I haven't systematically tested different versions/builds of
Outlook on different operating systems.

"Thomas Wetzel" <(E-Mail Removed)> wrote in message
news:bumf6k$nbb$02$(E-Mail Removed)...
> Hello Matt,
>
> what Outlook version?
>
> Thomas Wetzel
>
> "Matt Fletcher" <(E-Mail Removed)> wrote in message
> news:bujj00$249$(E-Mail Removed)...
> > I'm trying to prevent my add-in causing an access violation in MSMAPI32

at
> > 3552fe50. This occurs when an Outlook Window which was generated from

Send
> > To->Mail Recipient (on an explorer/desktop context menu) is closed. The
> > problem occurs in Windows 2000 and Windows 98, but not in Windows XP.
> >
> > The trap appears to be caused by sinking ItemEvents from a MailItemPtr

> which
> > is itself derived from the Inspector associated with a "Send To" Outlook
> > window.
> >
> > I have reproduced this problem using a test add-in: all it does is start

a
> > thread which sits in a loop waiting for an Application::Inspector to

give
> me
> > an InspectorPtr - when it does I call GetCurrentItem and sink the

events.
> > Sample code below - stripped of error handling and tracing for brevity.

(I
> > realise this is an unsophisticated way to get hold of the MailItem, but

it
> > gets round the lack of a NewInspector event).
> >
> > Any help with this particular brick wall greatly appreciated!
> >
> > Matt Fletcher
> >
> >
> > STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
> >

AddInDesignerObjects::ext_ConnectMode
> > ConnectMode,
> > IDispatch *pAddInInst,
> > SAFEARRAY ** /*custom*/ )
> > {
> > m_spOutlookApplication = (_ApplicationPtr)pApplication;
> > return S_OK;
> > }
> >
> > STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
> > {
> > DWORD dwID;
> > ::CreateThread(NULL, 0, SendToHandlerProc, (LPVOID)this, 0, &dwID);
> > return S_OK;
> > }
> >
> > void CConnect::AttachToMessage()
> > {
> > if (!m_bAttached)
> > {
> > _InspectorPtr spInspector =
> > m_spOutlookApplication->ActiveInspector();
> > if (spInspector)
> > {
> > m_spMailItem = spInspector->GetCurrentItem();
> > if (m_spMailItem)
> > {
> > MailItemEventsImpl:ispEventAdvise(m_spMailItem);
> > m_bAttached = true;
> > }
> > }
> > }
> > }
> >
> > DWORD WINAPI CConnect::SendToHandlerProc(LPVOID lpParameter)
> > {
> > CConnect * pConnect = (CConnect *)lpParameter;
> > while (!m_bAttached)
> > {
> > pConnect->AttachToMessage();
> > ::Sleep(500);
> > }
> >
> > return 0;
> > }
> >
> > STDMETHODIMP_(void) CConnect::OnItemClose(VARIANT_BOOL * Cancel)
> > {
> > MessageBox(NULL, "OnItemClose", "Debug", MB_OK);
> >
> > if (m_spMailItem)
> > MailItemEventsImpl:ispEventUnadvise(m_spMailItem);
> >
> > m_spMailItem = 0;
> > m_spOutlookApplication = 0;
> > }
> >
> >

>
>



 
Reply With Quote
 
Matt Fletcher
Guest
Posts: n/a
 
      22nd Jan 2004
Oh, and I should have added that the trap occurs in explorer, rather than
the Outlook process.

"Matt Fletcher" <(E-Mail Removed)> wrote in message
news:buo5f1$pfi$(E-Mail Removed)...
> I've reproduced the problem using Outlook XP (build 10.4219.4219) on

Windows
> 2000 and Outlook 2000 (build 9.0.0.3821) on Windows 98 (in a Virtual
> Machine). I haven't systematically tested different versions/builds of
> Outlook on different operating systems.
>
> "Thomas Wetzel" <(E-Mail Removed)> wrote in message
> news:bumf6k$nbb$02$(E-Mail Removed)...
> > Hello Matt,
> >
> > what Outlook version?
> >
> > Thomas Wetzel
> >
> > "Matt Fletcher" <(E-Mail Removed)> wrote in message
> > news:bujj00$249$(E-Mail Removed)...
> > > I'm trying to prevent my add-in causing an access violation in

MSMAPI32
> at
> > > 3552fe50. This occurs when an Outlook Window which was generated from

> Send
> > > To->Mail Recipient (on an explorer/desktop context menu) is closed.

The
> > > problem occurs in Windows 2000 and Windows 98, but not in Windows XP.
> > >
> > > The trap appears to be caused by sinking ItemEvents from a MailItemPtr

> > which
> > > is itself derived from the Inspector associated with a "Send To"

Outlook
> > > window.
> > >
> > > I have reproduced this problem using a test add-in: all it does is

start
> a
> > > thread which sits in a loop waiting for an Application::Inspector to

> give
> > me
> > > an InspectorPtr - when it does I call GetCurrentItem and sink the

> events.
> > > Sample code below - stripped of error handling and tracing for

brevity.
> (I
> > > realise this is an unsophisticated way to get hold of the MailItem,

but
> it
> > > gets round the lack of a NewInspector event).
> > >
> > > Any help with this particular brick wall greatly appreciated!
> > >
> > > Matt Fletcher
> > >
> > >
> > > STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
> > >

> AddInDesignerObjects::ext_ConnectMode
> > > ConnectMode,
> > > IDispatch *pAddInInst,
> > > SAFEARRAY ** /*custom*/ )
> > > {
> > > m_spOutlookApplication = (_ApplicationPtr)pApplication;
> > > return S_OK;
> > > }
> > >
> > > STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
> > > {
> > > DWORD dwID;
> > > ::CreateThread(NULL, 0, SendToHandlerProc, (LPVOID)this, 0,

&dwID);
> > > return S_OK;
> > > }
> > >
> > > void CConnect::AttachToMessage()
> > > {
> > > if (!m_bAttached)
> > > {
> > > _InspectorPtr spInspector =
> > > m_spOutlookApplication->ActiveInspector();
> > > if (spInspector)
> > > {
> > > m_spMailItem = spInspector->GetCurrentItem();
> > > if (m_spMailItem)
> > > {
> > > MailItemEventsImpl:ispEventAdvise(m_spMailItem);
> > > m_bAttached = true;
> > > }
> > > }
> > > }
> > > }
> > >
> > > DWORD WINAPI CConnect::SendToHandlerProc(LPVOID lpParameter)
> > > {
> > > CConnect * pConnect = (CConnect *)lpParameter;
> > > while (!m_bAttached)
> > > {
> > > pConnect->AttachToMessage();
> > > ::Sleep(500);
> > > }
> > >
> > > return 0;
> > > }
> > >
> > > STDMETHODIMP_(void) CConnect::OnItemClose(VARIANT_BOOL * Cancel)
> > > {
> > > MessageBox(NULL, "OnItemClose", "Debug", MB_OK);
> > >
> > > if (m_spMailItem)
> > > MailItemEventsImpl:ispEventUnadvise(m_spMailItem);
> > >
> > > m_spMailItem = 0;
> > > m_spOutlookApplication = 0;
> > > }
> > >
> > >

> >
> >

>
>



 
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
reminder eaccess violation window pop up Throwbax Windows Vista General Discussion 0 13th Dec 2007 03:43 AM
Closing popup window when closing parent window? =?Utf-8?B?Vk1J?= Microsoft ASP .NET 3 15th Feb 2007 08:29 AM
Closing child window and refreshing Parent window automatically =?Utf-8?B?U2lsZWVzaA==?= Microsoft ASP .NET 4 14th Oct 2004 03:01 AM
Parent window not closing HTTP Connections made by child window Sameer Fegade Windows XP Internet Explorer 1 25th Feb 2004 05:51 PM
Access Violation when closing Excel. Rich Microsoft Excel Programming 1 3rd Dec 2003 08:33 AM


Features
 

Advertising
 

Newsgroups
 


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