Click here to Skip to main content
15,895,799 members
Home / Discussions / C#
   

C#

 
GeneralRe: ComboBox problem windows application Pin
yogsworld2-May-06 19:36
yogsworld2-May-06 19:36 
GeneralRe: ComboBox problem windows application Pin
microsoc2-May-06 22:11
microsoc2-May-06 22:11 
QuestionHow to call Url from c# code Pin
Yuwraj2-May-06 18:56
Yuwraj2-May-06 18:56 
AnswerRe: How to call Url from c# code Pin
DigitalKing2-May-06 19:05
DigitalKing2-May-06 19:05 
QuestionNAPQ :( .. Getting custom controls to be displayed in toolbar Pin
malharone2-May-06 17:33
malharone2-May-06 17:33 
Questiondelete temp files program Pin
hops33n2-May-06 17:24
hops33n2-May-06 17:24 
AnswerRe: delete temp files program Pin
Judah Gabriel Himango2-May-06 17:29
sponsorJudah Gabriel Himango2-May-06 17:29 
AnswerRe: delete temp files program Pin
DigitalKing2-May-06 19:16
DigitalKing2-May-06 19:16 
When I came across the problem of clearing the IE history from a .net app, I searched for days before finding this solution.
It's not pretty, but it gets the job done. Yes, every line is required. Just call the ClearHistory method to do it.

Add these imports:
using System.Runtime.InteropServices;
using Microsoft.Win32;
Then,
[StructLayout(LayoutKind.Sequential)]
  private struct UUID
  {
      public int Data1;
      public short Data2;
      public short Data3;
      public byte[] Data4;
  }

  /// <summary>
  /// The structure that contains statistics about a URL. 
  /// </summary>
  [StructLayout(LayoutKind.Sequential)]
  private struct STATURL
  {
      /// <summary>
      /// Struct size
      /// </summary>
      public int cbSize;
      /// <summary>
      /// URL
      /// </summary>                                                                   
      [MarshalAs(UnmanagedType.LPWStr)]
      public string pwcsUrl;
      /// <summary>
      /// Page title
      /// </summary>
      [MarshalAs(UnmanagedType.LPWStr)]
      public string pwcsTitle;
      /// <summary>
      /// Last visited date (UTC)
      /// </summary>
      public System.Runtime.InteropServices.ComTypes.FILETIME ftLastVisited;
      /// <summary>
      /// Last updated date (UTC)
      /// </summary>
      public System.Runtime.InteropServices.ComTypes.FILETIME ftLastUpdated;
      /// <summary>
      /// The expiry date of the Web page's content (UTC)
      /// </summary>
      public System.Runtime.InteropServices.ComTypes.FILETIME ftExpires;
      /// <summary>
      /// Flags. STATURLFLAGS Enumaration.
      /// </summary>
      public uint dwFlags;
  }

  //Enumerates the cached URLs
  [ComImport]
  [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  [Guid("3C374A42-BAE4-11CF-BF7D-00AA006946EE")]
  private interface IEnumSTATURL
  {
      void Next(int celt, ref STATURL rgelt, out int pceltFetched);	//Returns the next \"celt\" URLS from the cache
      void Skip(int celt);	//Skips the next \"celt\" URLS from the cache. doed not work.
      void Reset();	//Resets the enumeration
      void Clone(out IEnumSTATURL ppenum);	//Clones this object
      void SetFilter([MarshalAs(UnmanagedType.LPWStr)] string poszFilter, uint dwFlags);	//Sets the enumeration filter
  }

  [ComImport]
  [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  [Guid("3C374A41-BAE4-11CF-BF7D-00AA006946EE")]
  private interface IUrlHistoryStg
  {
      void AddUrl(string pocsUrl, string pocsTitle, uint dwFlags);	//Adds a new history entry
      void DeleteUrl(string pocsUrl, int dwFlags);	//Deletes an entry by its URL. does not work!
      void QueryUrl([MarshalAs(UnmanagedType.LPWStr)] string pocsUrl, uint dwFlags, ref string lpSTATURL);	//Returns a STATURL for a given URL
      void BindToObject([In] string pocsUrl, [In] UUID riid, IntPtr ppvOut); //Binds to an object. does not work!
      object EnumUrls { [return: MarshalAs(UnmanagedType.IUnknown)] get;}	//Returns an enumerator for URLs
  }

  [ComImport]
  [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  [Guid("AFA0DC11-C313-11D0-831A-00C04FD5AE38")]
  private interface IUrlHistoryStg2 : IUrlHistoryStg
  {
      new void AddUrl(string pocsUrl, string pocsTitle, uint dwFlags);	//Adds a new history entry
      new void DeleteUrl(string pocsUrl, int dwFlags);	//Deletes an entry by its URL. does not work!
      void QueryUrl([MarshalAs(UnmanagedType.LPWStr)] string pocsUrl, uint dwFlags, ref STATURL lpSTATURL);	//Returns a STATURL for a given URL
      new void BindToObject([In] string pocsUrl, [In] UUID riid, IntPtr ppvOut);	//Binds to an object. does not work!
      new object EnumUrls { [return: MarshalAs(UnmanagedType.IUnknown)] get;}	//Returns an enumerator for URLs
   
      void AddUrlAndNotify(string pocsUrl, string pocsTitle, int dwFlags, int fWriteHistory, object poctNotify, object punkISFolder);//does not work!
      void ClearHistory();	//Removes all history items
  }

  //UrlHistory class
  [ComImport]
  [Guid("3C374A40-BAE4-11CF-BF7D-00AA006946EE")]
  private class UrlHistoryClass { }

  /// <summary>
  /// Clears the IE history of the current user.
  /// </summary>
  public static void ClearHistory()
  {
      UrlHistoryClass c = new UrlHistoryClass();
      ((IUrlHistoryStg2)c).ClearHistory();
  }

Sorry for the long post.

Hope this helps,
DigitalKing
AnswerRe: delete temp files program Pin
DigitalKing2-May-06 19:21
DigitalKing2-May-06 19:21 
GeneralRe: delete temp files program Pin
hops33n3-May-06 16:38
hops33n3-May-06 16:38 
Questiontab order in .net cf Pin
yongwpi2-May-06 16:42
yongwpi2-May-06 16:42 
QuestionDetecting Current Control When Mouse Moves With Button Down Pin
redfish342-May-06 16:06
redfish342-May-06 16:06 
QuestionMulti Threading in WinForms Pin
Shawn_H2-May-06 16:01
Shawn_H2-May-06 16:01 
AnswerRe: Multi Threading in WinForms Pin
Judah Gabriel Himango2-May-06 17:39
sponsorJudah Gabriel Himango2-May-06 17:39 
GeneralRe: Multi Threading in WinForms Pin
Shawn_H3-May-06 3:03
Shawn_H3-May-06 3:03 
QuestionRecursive method to search a folder w/ special condition Pin
WCup2-May-06 15:58
WCup2-May-06 15:58 
Questionsocket and tcp Pin
tjvictor2-May-06 15:29
tjvictor2-May-06 15:29 
AnswerRe: socket and tcp Pin
Jakob Farian Krarup2-May-06 23:58
Jakob Farian Krarup2-May-06 23:58 
QuestionGood reference book Pin
TheJudeDude2-May-06 13:15
TheJudeDude2-May-06 13:15 
QuestionCOM Interface Woes Pin
Daaron2-May-06 12:43
Daaron2-May-06 12:43 
Questionhow I can add more image in pictureBox Pin
mm3102-May-06 11:59
mm3102-May-06 11:59 
AnswerRe: how I can add more image in pictureBox Pin
Judah Gabriel Himango2-May-06 17:38
sponsorJudah Gabriel Himango2-May-06 17:38 
Questionhow to embedd exe file in my app as resource Programmaticaly ? Pin
hdv2122-May-06 11:40
hdv2122-May-06 11:40 
AnswerRe: how to embedd exe file in my app as resource Programmaticaly ? Pin
Ravi Bhavnani2-May-06 12:35
professionalRavi Bhavnani2-May-06 12:35 
Question[Message Deleted] Pin
Dr.Sammer2-May-06 9:39
Dr.Sammer2-May-06 9:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.