Browser Helper Object, problem with SHDocVw.DWebBrowserEvents2_Event.DocumentComplete

I'm writing Browser Helper Object (IExplorer plug-in) in C#, Microsoft VS 2005, Framework 2.0.

1. I implement interface IObjectWithSite and add event handler for events SHDocVw.DWebBrowserEvents2_Event.DocumentComplete and SHDocVw.DWebBrowserEvents2_Event.OnQuit in function SetSite :

[System.Runtime.InteropServices.ComImport, System.Runtime.InteropServices.Guid( "FC4801A3-2BA9-11CF-A229-00AA003D7352" ), System.Runtime.InteropServices.InterfaceType( System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown )]
public interface IObjectWithSite
{
void SetSite( [System.Runtime.InteropServices.In, System.Runtime.InteropServices.MarshalAs( System.Runtime.InteropServices.UnmanagedType.IUnknown )] object pUnkSite );
void GetSite( [System.Runtime.InteropServices.In] ref System.Guid riid, [System.Runtime.InteropServices.Out] System.IntPtr ppvSite );
}

[System.Runtime.InteropServices.ComVisible( true ), System.Runtime.InteropServices.Guid( "C06B3B91-769A-42d5-8BCD-CF70F8589FBA" ), System.Runtime.InteropServices.ClassInterface( System.Runtime.InteropServices.ClassInterfaceType.None )]
public class DOMPeek : IObjectWithSite
{
void IObjectWithSite.SetSite( object pUnkSite )
{
 if(m_IUnkSite != null)
 {
   System.Runtime.InteropServices.
Marshal.ReleaseComObject( m_IUnkSite );
 }
 m_IUnkSite = pUnkSite;

 try
 
{
   SHDocVw.
DWebBrowserEvents2_Event WebBrowserEvents = (SHDocVw.DWebBrowserEvents2_Event)m_IUnkSite;
   WebBrowserEvents.DocumentComplete += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler( OnDocumentComplete );
  
WebBrowserEvents.OnQuit += new SHDocVw.DWebBrowserEvents2_OnQuitEventHandler( OnQuit );
 
}
 
catch // cast or no such interface exception
 
{
 }
 return;
}

void IObjectWithSite.GetSite( ref System.Guid riid, System.IntPtr ppvSite )
{
}

2. Implement event handlers OnQuit and DocumentComplete

void OnQuit()
{
  System.Windows.Forms.MessageBox.Show( "OnQuit" );
}

void OnDocumentComplete( object pDispatch, ref object VariantURL )
{
  System.Windows.Forms.MessageBox.Show( "OnDocumentComplete : " + VariantURL );
}

3. I register the object DOMPeek as Browser Helper Object in windows register.

Then I run IExplorer and see the messageBox "OnDocumentComplete : about:blank". Then I close IE window and see the messageBox "OnQuite".

The problem consist in that I take this result only in MSWindows2003sp1 (server) with MS VS2005 installed. In MSWindowsXPsp2 without any updates, without MS VS2005, but with all Frameworks installed I didn't see the messageBox "OnDocumentComplete : about:blank", but see the messageBox "OnQuit". What's problem What updates need for correct working in MSWindowsXPsp2

Then I try to install all updates for MSWindowsXPsp2 from Microsoft site and again didn't see the messageBox "OnDocumentComplete : about:blank", but see the messageBox "OnQuit". Then I try to install MS VS2005 but didn't install all updates for MSWindowsXPsp2  and again didn't see the messageBox "OnDocumentComplete : about:blank", but see the messageBox "OnQuit". Finally I install all updates for MSWindowsXPsp2 from microsoft site and then MS VS2005 then I see the messageBox "OnDocumentComplete : about:blank" and "OnQuit". But if I install MS VS2005 and then all updates for MSWindowsXPsp2 then not woking (didn't see the messageBox "OnDocumentComplete : about:blank", but see the messageBox "OnQuit").

What's problem What specifically updates need for correct working in MSWindowsXPsp2



Answer this question

Browser Helper Object, problem with SHDocVw.DWebBrowserEvents2_Event.DocumentComplete

  • Browser Helper Object, problem with SHDocVw.DWebBrowserEvents2_Event.DocumentComplete