Click here to Skip to main content
15,916,945 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow to delete Temp Files and IE history? Pin
Lucktas26-Jun-04 22:54
Lucktas26-Jun-04 22:54 
AnswerRe: How to delete Temp Files and IE history? Pin
A_Yakout27-Jun-04 0:53
A_Yakout27-Jun-04 0:53 
GeneralRe: How to delete Temp Files and IE history? Pin
Lucktas27-Jun-04 2:52
Lucktas27-Jun-04 2:52 
GeneralRe: How to delete Temp Files and IE history? Pin
A_Yakout27-Jun-04 19:18
A_Yakout27-Jun-04 19:18 
AnswerRe: How to delete Temp Files and IE history? Pin
Aaron Eldreth28-Jun-04 3:45
Aaron Eldreth28-Jun-04 3:45 
GeneralRe: How to delete Temp Files and IE history? Pin
Lucktas28-Jun-04 7:19
Lucktas28-Jun-04 7:19 
GeneralRe: How to delete Temp Files and IE history? Pin
Dave Kreskowiak28-Jun-04 9:48
mveDave Kreskowiak28-Jun-04 9:48 
GeneralRe: How to delete Temp Files and IE history? Pin
Dave Kreskowiak28-Jun-04 15:37
mveDave Kreskowiak28-Jun-04 15:37 
OK... I've got an example working. It's based on the work by goblins in this[^] article here on CodeProject. The code to actually make the call looks something like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim urlHistory As New UrlHistoryClass
    Dim obj As IUrlHistoryStg2 = CType(urlHistory, IUrlHistoryStg2)
    obj.ClearHistory()
    Marshal.ReleaseComObject(obj)
End Sub

You have to make the call TWICE. Once to clear out the History and a second time to clear out the Cached Files History.

The code to make the call HAPPEN looks like this (in C#, I don't have the time to convert it to VB.NET):
using System;
using System.Runtime.InteropServices;
using System.Collections;
 
namespace Obsolete
{
	public enum STATURL_QUERYFLAGS : uint
	{
		STATURL_QUERYFLAG_ISCACHED = 0x00010000,
		STATURL_QUERYFLAG_NOURL    = 0x00020000,
		STATURL_QUERYFLAG_NOTITLE  = 0x00040000,
		STATURL_QUERYFLAG_TOPLEVEL = 0x00080000,
	}
	public enum STATURLFLAGS : uint
	{
		STATURLFLAG_ISCACHED   = 0x00000001,
		STATURLFLAG_ISTOPLEVEL = 0x00000002,
	}
 
	//Contains statistics about a URL
	[StructLayout(LayoutKind.Sequential)]
	public struct STATURL 
	{
		public int cbSize;
		[MarshalAs(UnmanagedType.LPWStr)] public string pwcsUrl;
		[MarshalAs(UnmanagedType.LPWStr)] public string pwcsTitle;
		public FILETIME ftLastVisited;
		public FILETIME ftLastUpdated;
		public FILETIME ftExpires;
		public STATURLFLAGS dwFlags;
	} 
 
	[StructLayout(LayoutKind.Sequential)]
	public struct UUID
	{
		public int Data1;
		public short Data2;
		public short Data3;
		public byte[] Data4;
	}
 
	//Enumerates the cached URLs
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("3C374A42-BAE4-11CF-BF7D-00AA006946EE")]
	public interface IEnumSTATURL 
	{
		void Next(int celt, ref STATURL rgelt, out int pceltFetched);
		void Skip(int celt);
		void Reset();
		void Clone(out IEnumSTATURL ppenum);
		void SetFilter([MarshalAs(UnmanagedType.LPWStr)] string  poszFilter, STATURLFLAGS dwFlags);
	}
 	
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("3C374A41-BAE4-11CF-BF7D-00AA006946EE")]
	public interface IUrlHistoryStg
	{
		void AddUrl(string pocsUrl, string pocsTitle, STATURLFLAGS dwFlags);
		void DeleteUrl(string pocsUrl, int dwFlags);
		void QueryUrl ([MarshalAs(UnmanagedType.LPWStr)] string pocsUrl , int dwFlags , ref STATURL lpSTATURL );
		void BindToObject ([In] string pocsUrl, [In] UUID riid, IntPtr ppvOut);
		object EnumUrls{[return: MarshalAs(UnmanagedType.IUnknown)] get;}
	}
 
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("AFA0DC11-C313-11D0-831A-00C04FD5AE38")]
	public interface IUrlHistoryStg2 : IUrlHistoryStg
	{
		new void AddUrl(string pocsUrl, string pocsTitle, STATURLFLAGS dwFlags);
		new void DeleteUrl(string pocsUrl, int dwFlags);
		new void QueryUrl ([MarshalAs(UnmanagedType.LPWStr)] string pocsUrl , int dwFlags , ref STATURL lpSTATURL );
		new void BindToObject ([In] string pocsUrl, [In] UUID riid, IntPtr ppvOut);
		new object EnumUrls{[return: MarshalAs(UnmanagedType.IUnknown)] get;}
		void AddUrlAndNotify(string pocsUrl, string pocsTitle, int dwFlags, int fWriteHistory, object poctNotify, object punkISFolder);
		void ClearHistory();
	}
 
	//UrlHistory class
	[ComImport]
	[Guid("3C374A40-BAE4-11CF-BF7D-00AA006946EE")]
	public class UrlHistoryClass
	{	
	}
}

That's alot of work to clear out the History and Temporary Internet Files.

RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

GeneralRe: How to delete Temp Files and IE history? Pin
Aaron Eldreth29-Jun-04 2:25
Aaron Eldreth29-Jun-04 2:25 
GeneralRe: How to delete Temp Files and IE history? Pin
Lucktas29-Jun-04 6:17
Lucktas29-Jun-04 6:17 
Generalopening MS Excel spreadsheet Pin
lxhan26-Jun-04 19:55
lxhan26-Jun-04 19:55 
GeneralRe: opening MS Excel spreadsheet Pin
tanstaafl2827-Jun-04 19:11
tanstaafl2827-Jun-04 19:11 
GeneralRe: opening MS Excel spreadsheet Pin
Anonymous6-Jul-04 9:57
Anonymous6-Jul-04 9:57 
QuestionHow can I rename an NT user using the ADSI? Pin
zzzhouzhou26-Jun-04 5:39
zzzhouzhou26-Jun-04 5:39 
AnswerRe: How can I rename an NT user using the ADSI? Pin
Dave Kreskowiak28-Jun-04 2:46
mveDave Kreskowiak28-Jun-04 2:46 
GeneralRe: How can I rename an NT user using the ADSI? Pin
zzzhouzhou26-Jul-04 17:01
zzzhouzhou26-Jul-04 17:01 
GeneralSystem.Configuration Namespace Pin
beowulfagate25-Jun-04 22:13
beowulfagate25-Jun-04 22:13 
GeneralRe: System.Configuration Namespace Pin
tanstaafl2826-Jun-04 4:23
tanstaafl2826-Jun-04 4:23 
GeneralRe: System.Configuration Namespace Pin
beowulfagate26-Jun-04 17:58
beowulfagate26-Jun-04 17:58 
GeneralRe: System.Configuration Namespace Pin
Dave Kreskowiak26-Jun-04 18:04
mveDave Kreskowiak26-Jun-04 18:04 
GeneralRe: System.Configuration Namespace Pin
beowulfagate27-Jun-04 13:35
beowulfagate27-Jun-04 13:35 
GeneralRe: System.Configuration Namespace Pin
beowulfagate27-Jun-04 14:41
beowulfagate27-Jun-04 14:41 
GeneralRe: System.Configuration Namespace Pin
Dave Kreskowiak27-Jun-04 18:15
mveDave Kreskowiak27-Jun-04 18:15 
GeneralRe: System.Configuration Namespace Pin
beowulfagate27-Jun-04 20:31
beowulfagate27-Jun-04 20:31 
GeneralRe: System.Configuration Namespace Pin
Dave Kreskowiak28-Jun-04 0:36
mveDave Kreskowiak28-Jun-04 0:36 

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.