Grigory Bushuev

 
I want to get WebControl history via ITravelLogStg implementation, 
but when i calling wrapped methods thrown exceptions or returns incorrect values(see the comments).
Help me please. Thank you. 
  [ComImport]
  [Guid("6d5140c1-7436-11ce-8034-00aa006009fa")]
  [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  public interface IServiceProvider
  {
    void QueryService(ref Guid guidService, ref Guid riid,
      [Out, MarshalAs(UnmanagedType.Interface)] out object ppvObject);
  }

  public BrowserHistory(System.Windows.Forms.WebBrowser webBrowser)
  {
    if (webBrowser == null)
      throw new ArgumentNullException("         webBrowser                     ");
    
    Guid SID_STravelLogCursor = new Guid("7EBFDD80-AD18-11d3-A4C5-00C04F72D6B8");
    Guid IID_ITravelLogStg = typeof (ITravelLogStg).GUID;
    
    SHDocVw.IWebBrowser2 axWebBrowser = null;

    IServiceProvider pISP = null;      

    axWebBrowser = (SHDocVw.IWebBrowser2)webBrowser.ActiveXInstance;

    pISP = (IServiceProvider) axWebBrowser;
    
    object ppvObject = null;
    pISP.QueryService(ref SID_STravelLogCursor, ref IID_ITravelLogStg, out ppvObject);
    _travelLogStg = (ITravelLogStg) ppvObject;
  }

    public int GetCount(TLENUMF flag)
    {
      int result;
      _travelLogStg.GetCount(flag, out result);
      //Return incorrect value
		return result;
    }

    public IList<TravelLogEntry> EnumEntries(TLENUMF flags, int maxEntries)
    {
      List<TravelLogEntry> travelLogEntries = new List<TravelLogEntry>();
      IEnumTravelLogEntry enumTravelLogEntry = null;
      //Thrown System.AccessViolationException was unhandled
	  // Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
      if (_travelLogStg.EnumEntries(flags, out enumTravelLogEntry) == S_FALSE) return null;
    }

  [ComImport()]
  [ComVisible(false)]
  [Guid("7EBFDD80-AD18-11d3-A4C5-00C04F72D6B8")]
  [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  public interface ITravelLogStg
  {

     //Some code

    [PreserveSig]
    int EnumEntries([In(), MarshalAs(UnmanagedType.U4)] TLENUMF flags,
            [Out(), MarshalAs(UnmanagedType.Interface)] out IEnumTravelLogEntry ppenum);


    [PreserveSig]
    int GetCount([In(), MarshalAs(UnmanagedType.U4)]TLENUMF flags, 
           [Out(), MarshalAs(UnmanagedType.U4)] out int pcEntries);
  }