Click here to Skip to main content
15,904,822 members
Home / Discussions / C#
   

C#

 
GeneralRe: Error Pin
Travis D. Mathison3-May-06 3:40
Travis D. Mathison3-May-06 3:40 
GeneralRe: Error Pin
Hamid_RT3-May-06 3:51
Hamid_RT3-May-06 3:51 
GeneralRe: Error Pin
Travis D. Mathison3-May-06 4:16
Travis D. Mathison3-May-06 4:16 
GeneralRe: Error Pin
Hamid_RT3-May-06 4:32
Hamid_RT3-May-06 4:32 
Questionwindows messaging constants Pin
kumar.bs2-May-06 20:38
kumar.bs2-May-06 20:38 
AnswerRe: windows messaging constants Pin
alexey N2-May-06 20:53
alexey N2-May-06 20:53 
GeneralRe: windows messaging constants Pin
kumar.bs2-May-06 21:13
kumar.bs2-May-06 21:13 
GeneralRe: windows messaging constants Pin
microsoc2-May-06 21:55
microsoc2-May-06 21:55 
QuestionSQL Querry Pin
cshivaprasad2-May-06 20:06
cshivaprasad2-May-06 20:06 
AnswerRe: SQL Querry Pin
Naveed N Malik2-May-06 21:48
Naveed N Malik2-May-06 21:48 
AnswerRe: SQL Querry Pin
Guffa2-May-06 21:54
Guffa2-May-06 21:54 
QuestionGlobal varaible Decleration Pin
abhinish2-May-06 19:39
abhinish2-May-06 19:39 
AnswerRe: Global varaible Decleration Pin
Christian Graus2-May-06 20:03
protectorChristian Graus2-May-06 20:03 
QuestionComboBox problem windows application Pin
yogsworld2-May-06 19:20
yogsworld2-May-06 19:20 
AnswerRe: ComboBox problem windows application Pin
DigitalKing2-May-06 19:28
DigitalKing2-May-06 19:28 
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 

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.