cookey
asked on
Delete all Temporary Internet Files
How to delete all Temporary Internet Files and all history urls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Guess i dont have to.
inthe just knows it all ;-D
inthe just knows it all ;-D
ASKER
Yes, I find the way in http://www.euromind.com/iedelphi/IECache.htm
, but, It must install a component, i want to know a simple way to delete files, I think delete everything in \windows\temporary internet files\ is a good idea, but, it seems not delete completly
, but, It must install a component, i want to know a simple way to delete files, I think delete everything in \windows\temporary internet files\ is a good idea, but, it seems not delete completly
i can give some code for it but its alot of code and is different depending on what version of windows the program is running on.
need to check what version is running
then read a string from registry(read path to temp internet files dir from reg)
then delete all files using findfirst etc in loop..
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Registry;
type
TForm1 = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function FindTemporaryFiles : String;
var
TheReg : TRegistry;
TempString : String;
begin
TheReg := TRegistry.Create;
try
TheReg.RootKey := HKEY_LOCAL_MACHINE;
If TheReg.OpenKey('Software\M icrosoft\I nternet Explorer\Main\', False ) then
begin
TempString := TheReg.ReadString('Cache_D irectory') ;
If Copy(TempString, Length(TempString) - 1, 1) <> '\' then
TempString := TempString + '\';
Result := TempString;
end
else
Result := 'NOTHING';
finally
TheReg.Free;
end;
end;
procedure GatherFiles(Const Lines: TStrings; Const Dir,Match: String);
var
Rec: TSearchRec;
Found: Integer;
Begin
// Add files
Found:= FindFirst(Dir+'\'+Match, faAnyFile, Rec);
While Found = 0 do
begin
If (Rec.Attr AND faDirectory) = 0 Then Lines.Add(Dir+'\'+Rec.Name );
Found := FindNext(Rec);
End;
FindClose(Rec);
// Find directories (Without match)
Found:= FindFirst(Dir+'\*.*', faAnyFile, Rec);
While Found = 0 do
begin
If ((Rec.Attr AND faDirectory)>0) AND (Rec.Name<>'.') AND (Rec.Name<>'..') Then
GatherFiles(Lines,Dir+'\'+ Rec.Name,M atch);
Found := FindNext(Rec);
End;
FindClose(Rec);
End;
procedure TForm1.Button1Click(Sender : TObject);
Var
TempPath : String;
TheList : TStringList;
i : integer;
begin
TheList := TStringList.Create;
try
TempPath := FindTemporaryFiles;
If (length(TempPath) > 3) AND (UPPERCASE(TempPath) <> 'C:\WINDOWS') AND (UPPERCASE(TempPath) <> 'C:\WINNT') then
begin
GatherFiles(TheList,TempPa th,'*.*');
For i := 0 to TheList.Count - 1 do
try
// DeleteFile( TheList[i] );
combobox1.items.add(TheLis t[i]);
except
end;
End;
finally
TheList.Free;
end;
showmessage('finished');
end;
end.
for win9* pc's the above wil work if you just change the registry path to hkcu \Software\Microsoft\Window s\CurrentV ersion\Exp lorer\Shel l Folders\ and read the string "cache" .
here another example maybe works on both (UNTESTED on nt):
unit UrlH_Unit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Activex, Comobj, StdCtrls, ComCtrls, Grids;
const
STATURL_QUERYFLAG_ISCACHED = $00010000;
STATURL_QUERYFLAG_NOURL = $00020000;
STATURL_QUERYFLAG_NOTITLE = $00040000;
STATURL_QUERYFLAG_TOPLEVEL = $00080000;
STATURLFLAG_ISCACHED = $00000001;
STATURLFLAG_ISTOPLEVEL = $00000002;
IID_IEnumStatUrl: TGUID = (D1: $3C374A42; D2: $BAE4; D3: $11CF; D4: ($BF, $7D, $00, $AA, $00, $69, $46, $EE));
IID_IUrlHistoryStg: TGUID = (D1: $3C374A41; D2: $BAE4; D3: $11CF; D4: ($BF, $7D, $00, $AA, $00, $69, $46, $EE));
IID_IUrlHistoryStg2: TGUID = (D1: $AFA0DC11; D2: $C313; D3: $831A; D4: ($83, $1A, $00, $C0, $4F, $D5, $AE, $38));
IID_IUrlHistoryNotify: TGUID = (D1: $BC40BEC1; D2: $C493; D3: $11D0; D4: ($83, $1B, $00, $C0, $4F, $D5, $AE, $38));
SID_IEnumStatUrl = '{3C374A42-BAE4-11CF-BF7D- 00AA006946 EE}';
SID_IUrlHistoryStg = '{3C374A41-BAE4-11CF-BF7D- 00AA006946 EE}';
SID_IUrlHistoryStg2 = '{AFA0DC11-C313-11d0-831A- 00C04FD5AE 38}';
SID_IURLHistoryNotify = '{BC40BEC1-C493-11d0-831B- 00C04FD5AE 38}';
CLSID_CUrlHistory: TGUID = '{3C374A40-BAE4-11CF-BF7D- 00AA006946 EE}';
type
STATURL = record
cbSize: DWORD;
pwcsUrl: DWORD;
pwcsTitle: DWORD;
ftLastVisited: FILETIME;
ftLastUpdated: FILETIME;
ftExpires: FILETIME;
dwFlags: DWORD;
end;
IEnumSTATURL = interface(IUnknown)
['{3C374A42-BAE4-11CF-BF7D -00AA00694 6EE}']
function Next(celt: Integer; out elt; pceltFetched: PLongint): HRESULT; stdcall;
function Skip(celt: Longint): HRESULT; stdcall;
function Reset: HResult; stdcall;
function Clone(out ppenum: IEnumSTATURL): HResult; stdcall;
function SetFilter(poszFilter: PWideChar; dwFlags: DWORD): HResult; stdcall;
end;
IUrlHistoryStg = interface(IUnknown)
['{3C374A41-BAE4-11CF-BF7D -00AA00694 6EE}']
function AddUrl(pocsUrl: PWideChar; pocsTitle: PWideChar; dwFlags: Integer): HResult; stdcall;
function DeleteUrl(pocsUrl: PWideChar; dwFlags: Integer): HResult; stdcall;
function QueryUrl(pocsUrl: PWideChar; dwFlags: Integer; var lpSTATURL: STATURL): HResult; stdcall;
function BindToObject(pocsUrl: PWideChar; var riid: TIID; out ppvOut: Pointer): HResult; stdcall;
function EnumUrls(out ppenum: IEnumSTATURL): HResult; stdcall;
end;
IUrlHistoryStg2 = interface(IUrlHistoryStg)
['{AFA0DC11-C313-11D0-831A -00C04FD5A E38}']
function AddUrlAndNotify(pocsUrl: PWideChar; pocsTitle: PWideChar; dwFlags: Integer;
fWriteHistory: Integer; var poctNotify: Pointer;
const punkISFolder: IUnknown): HResult; stdcall;
function ClearHistory: HResult; stdcall;
end;
IUrlHistoryNotify = interface(IOleCommandTarge t)
['{BC40BEC1-C493-11d0-831B -00C04FD5A E38}']
end;
TForm1 = class(TForm)
StringGrid1: TStringGrid;
RetrieveBtn: TButton;
ClearBtn: TButton;
procedure RetrieveBtnClick(Sender: TObject);
procedure ClearBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
I: IUrlHistoryStg2;
implementation
{$R *.DFM}
function FileTimeToDt(Ft: TFileTime): TDateTime;
var
l: Integer;
lft: TFileTime;
begin
FileTimeToLocalFiletime(Ft , lft);
if FileTimeToDosDateTime(lft, Longrec(l).Hi, Longrec(l).Lo) then
result := FiledateToDatetime(l) else
result := 0;
end;
procedure TForm1.RetrieveBtnClick(Se nder: TObject);
var
r: Staturl;
Enum: IEnumStatUrl;
X: Integer;
Row: Integer;
begin
StringGrid1.Cells[0, 0] := 'Last Visited';
StringGrid1.Cells[1, 0] := 'Title';
StringGrid1.Cells[2, 0] := 'Url';
StringGrid1.Cells[3, 0] := 'Last Updated';
StringGrid1.Cells[4, 0] := 'Expires';
Row := 0;
I := CreateComObject(ClsId_CUrl History) as IUrlHistoryStg2;
I.EnumUrls(Enum);
Enum.SetFilter('http://', 0);
while enum.next(1, r, @X) = S_OK do begin
Inc(Row);
StringGrid1.RowCount := Row + 1;
Stringgrid1.Cells[0, Row] := DateTimeToStr(FileTimeToDt (r.ftLastV isited));
Stringgrid1.Cells[1, Row] := PWidechar(Pointer(r.pwcsTi tle));
Stringgrid1.Cells[2, Row] := PWidechar(Pointer(r.pwcsUr l));
Stringgrid1.Cells[3, Row] := DateTimeToStr(FileTimeToDt (r.ftLastU pdated));
Stringgrid1.Cells[4, Row] := DateTimeToStr(FileTimeToDt (r.ftExpir es));
end;
end;
procedure TForm1.ClearBtnClick(Sende r: TObject);
begin
I.ClearHistory;
end;
end.
form as text:
object Form1: TForm1
Left = 192
Top = 107
Width = 763
Height = 349
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object StringGrid1: TStringGrid
Left = 0
Top = 0
Width = 755
Height = 257
Align = alTop
DefaultRowHeight = 14
FixedCols = 0
TabOrder = 0
ColWidths = (
103
205
207
113
150)
end
object RetrieveBtn: TButton
Left = 208
Top = 282
Width = 137
Height = 25
Caption = 'Enumerate UrlHistory'
TabOrder = 1
OnClick = RetrieveBtnClick
end
object ClearBtn: TButton
Left = 448
Top = 282
Width = 137
Height = 25
Caption = 'Clear UrlHistory'
TabOrder = 2
OnClick = ClearBtnClick
end
end
always pays to check what files are really going to be deleted by loading to a combobox first ..
Regards Barry
need to check what version is running
then read a string from registry(read path to temp internet files dir from reg)
then delete all files using findfirst etc in loop..
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Registry;
type
TForm1 = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function FindTemporaryFiles : String;
var
TheReg : TRegistry;
TempString : String;
begin
TheReg := TRegistry.Create;
try
TheReg.RootKey := HKEY_LOCAL_MACHINE;
If TheReg.OpenKey('Software\M
begin
TempString := TheReg.ReadString('Cache_D
If Copy(TempString, Length(TempString) - 1, 1) <> '\' then
TempString := TempString + '\';
Result := TempString;
end
else
Result := 'NOTHING';
finally
TheReg.Free;
end;
end;
procedure GatherFiles(Const Lines: TStrings; Const Dir,Match: String);
var
Rec: TSearchRec;
Found: Integer;
Begin
// Add files
Found:= FindFirst(Dir+'\'+Match, faAnyFile, Rec);
While Found = 0 do
begin
If (Rec.Attr AND faDirectory) = 0 Then Lines.Add(Dir+'\'+Rec.Name
Found := FindNext(Rec);
End;
FindClose(Rec);
// Find directories (Without match)
Found:= FindFirst(Dir+'\*.*', faAnyFile, Rec);
While Found = 0 do
begin
If ((Rec.Attr AND faDirectory)>0) AND (Rec.Name<>'.') AND (Rec.Name<>'..') Then
GatherFiles(Lines,Dir+'\'+
Found := FindNext(Rec);
End;
FindClose(Rec);
End;
procedure TForm1.Button1Click(Sender
Var
TempPath : String;
TheList : TStringList;
i : integer;
begin
TheList := TStringList.Create;
try
TempPath := FindTemporaryFiles;
If (length(TempPath) > 3) AND (UPPERCASE(TempPath) <> 'C:\WINDOWS') AND (UPPERCASE(TempPath) <> 'C:\WINNT') then
begin
GatherFiles(TheList,TempPa
For i := 0 to TheList.Count - 1 do
try
// DeleteFile( TheList[i] );
combobox1.items.add(TheLis
except
end;
End;
finally
TheList.Free;
end;
showmessage('finished');
end;
end.
for win9* pc's the above wil work if you just change the registry path to hkcu \Software\Microsoft\Window
here another example maybe works on both (UNTESTED on nt):
unit UrlH_Unit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Activex, Comobj, StdCtrls, ComCtrls, Grids;
const
STATURL_QUERYFLAG_ISCACHED
STATURL_QUERYFLAG_NOURL = $00020000;
STATURL_QUERYFLAG_NOTITLE = $00040000;
STATURL_QUERYFLAG_TOPLEVEL
STATURLFLAG_ISCACHED = $00000001;
STATURLFLAG_ISTOPLEVEL = $00000002;
IID_IEnumStatUrl: TGUID = (D1: $3C374A42; D2: $BAE4; D3: $11CF; D4: ($BF, $7D, $00, $AA, $00, $69, $46, $EE));
IID_IUrlHistoryStg: TGUID = (D1: $3C374A41; D2: $BAE4; D3: $11CF; D4: ($BF, $7D, $00, $AA, $00, $69, $46, $EE));
IID_IUrlHistoryStg2: TGUID = (D1: $AFA0DC11; D2: $C313; D3: $831A; D4: ($83, $1A, $00, $C0, $4F, $D5, $AE, $38));
IID_IUrlHistoryNotify: TGUID = (D1: $BC40BEC1; D2: $C493; D3: $11D0; D4: ($83, $1B, $00, $C0, $4F, $D5, $AE, $38));
SID_IEnumStatUrl = '{3C374A42-BAE4-11CF-BF7D-
SID_IUrlHistoryStg = '{3C374A41-BAE4-11CF-BF7D-
SID_IUrlHistoryStg2 = '{AFA0DC11-C313-11d0-831A-
SID_IURLHistoryNotify = '{BC40BEC1-C493-11d0-831B-
CLSID_CUrlHistory: TGUID = '{3C374A40-BAE4-11CF-BF7D-
type
STATURL = record
cbSize: DWORD;
pwcsUrl: DWORD;
pwcsTitle: DWORD;
ftLastVisited: FILETIME;
ftLastUpdated: FILETIME;
ftExpires: FILETIME;
dwFlags: DWORD;
end;
IEnumSTATURL = interface(IUnknown)
['{3C374A42-BAE4-11CF-BF7D
function Next(celt: Integer; out elt; pceltFetched: PLongint): HRESULT; stdcall;
function Skip(celt: Longint): HRESULT; stdcall;
function Reset: HResult; stdcall;
function Clone(out ppenum: IEnumSTATURL): HResult; stdcall;
function SetFilter(poszFilter: PWideChar; dwFlags: DWORD): HResult; stdcall;
end;
IUrlHistoryStg = interface(IUnknown)
['{3C374A41-BAE4-11CF-BF7D
function AddUrl(pocsUrl: PWideChar; pocsTitle: PWideChar; dwFlags: Integer): HResult; stdcall;
function DeleteUrl(pocsUrl: PWideChar; dwFlags: Integer): HResult; stdcall;
function QueryUrl(pocsUrl: PWideChar; dwFlags: Integer; var lpSTATURL: STATURL): HResult; stdcall;
function BindToObject(pocsUrl: PWideChar; var riid: TIID; out ppvOut: Pointer): HResult; stdcall;
function EnumUrls(out ppenum: IEnumSTATURL): HResult; stdcall;
end;
IUrlHistoryStg2 = interface(IUrlHistoryStg)
['{AFA0DC11-C313-11D0-831A
function AddUrlAndNotify(pocsUrl: PWideChar; pocsTitle: PWideChar; dwFlags: Integer;
fWriteHistory: Integer; var poctNotify: Pointer;
const punkISFolder: IUnknown): HResult; stdcall;
function ClearHistory: HResult; stdcall;
end;
IUrlHistoryNotify = interface(IOleCommandTarge
['{BC40BEC1-C493-11d0-831B
end;
TForm1 = class(TForm)
StringGrid1: TStringGrid;
RetrieveBtn: TButton;
ClearBtn: TButton;
procedure RetrieveBtnClick(Sender: TObject);
procedure ClearBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
I: IUrlHistoryStg2;
implementation
{$R *.DFM}
function FileTimeToDt(Ft: TFileTime): TDateTime;
var
l: Integer;
lft: TFileTime;
begin
FileTimeToLocalFiletime(Ft
if FileTimeToDosDateTime(lft,
result := FiledateToDatetime(l) else
result := 0;
end;
procedure TForm1.RetrieveBtnClick(Se
var
r: Staturl;
Enum: IEnumStatUrl;
X: Integer;
Row: Integer;
begin
StringGrid1.Cells[0, 0] := 'Last Visited';
StringGrid1.Cells[1, 0] := 'Title';
StringGrid1.Cells[2, 0] := 'Url';
StringGrid1.Cells[3, 0] := 'Last Updated';
StringGrid1.Cells[4, 0] := 'Expires';
Row := 0;
I := CreateComObject(ClsId_CUrl
I.EnumUrls(Enum);
Enum.SetFilter('http://', 0);
while enum.next(1, r, @X) = S_OK do begin
Inc(Row);
StringGrid1.RowCount := Row + 1;
Stringgrid1.Cells[0, Row] := DateTimeToStr(FileTimeToDt
Stringgrid1.Cells[1, Row] := PWidechar(Pointer(r.pwcsTi
Stringgrid1.Cells[2, Row] := PWidechar(Pointer(r.pwcsUr
Stringgrid1.Cells[3, Row] := DateTimeToStr(FileTimeToDt
Stringgrid1.Cells[4, Row] := DateTimeToStr(FileTimeToDt
end;
end;
procedure TForm1.ClearBtnClick(Sende
begin
I.ClearHistory;
end;
end.
form as text:
object Form1: TForm1
Left = 192
Top = 107
Width = 763
Height = 349
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object StringGrid1: TStringGrid
Left = 0
Top = 0
Width = 755
Height = 257
Align = alTop
DefaultRowHeight = 14
FixedCols = 0
TabOrder = 0
ColWidths = (
103
205
207
113
150)
end
object RetrieveBtn: TButton
Left = 208
Top = 282
Width = 137
Height = 25
Caption = 'Enumerate UrlHistory'
TabOrder = 1
OnClick = RetrieveBtnClick
end
object ClearBtn: TButton
Left = 448
Top = 282
Width = 137
Height = 25
Caption = 'Clear UrlHistory'
TabOrder = 2
OnClick = ClearBtnClick
end
end
always pays to check what files are really going to be deleted by loading to a combobox first ..
Regards Barry
the first example posted above is for nt unless the reg key is changed.
i prefer the euromind methods because i consider them "safer" to use.
i prefer the euromind methods because i consider them "safer" to use.
ASKER
I tried the second example, It only delete files in "History" directory, can't delete files in "Temporary Internet Files". Must I use 1st example to delete files in "Temporary Internet Files"?
unit Cacheunit;
interface
uses
WinInet, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
RetrieveBtn: TButton;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure ListBox1Click(Sender: TObject);
procedure RetrieveBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function GetUrlCacheEntryInfo(lpszU rlName: PChar; lpCacheEntryInfo:
PInternetCacheEntryInfo; var lpdwCacheEntryInfoBufferSi ze: DWORD): BOOL; stdcall;
function FindFirstUrlCacheEntry(lps zUrlSearch Pattern: PChar;
lpFirstCacheEntryInfo: PInternetCacheEntryInfo;
var lpdwFirstCacheEntryInfoBuf ferSize: DWORD): THandle; stdcall;
function FindNextUrlCacheEntry(hEnu mHandle: THandle; lpNextCacheEntryInfo:
PInternetCacheEntryInfo; var lpdwNextCacheEntryInfoBuff erSize: DWORD): BOOL; stdcall;
var
Form1: TForm1;
implementation
{$R *.DFM}
const
URLHISTORY_CACHE_ENTRY = $00200000;
winetdll = 'wininet.dll';
function FindFirstUrlCacheEntry; external winetdll name 'FindFirstUrlCacheEntryA';
function FindNextUrlCacheEntry; external winetdll name 'FindNextUrlCacheEntryA';
function GetUrlCacheEntryInfo; external winetdll name 'GetUrlCacheEntryInfoA';
function FileTimeToDt(Ft: TFileTime): string;
var
l: Integer;
lft: TFileTime;
begin
FileTimeToLocalFiletime(Ft , lft);
if FileTimeToDosDateTime(lft, Longrec(l).Hi, Longrec(l).Lo) then
result := DateTimeToStr(FiledateToDa tetime(l)) else
result := '';
end;
procedure TForm1.ListBox1Click(Sende r: TObject);
var
T: PInternetCacheEntryInfo;
D: Cardinal;
begin
D := 0;
GetUrlCacheEntryInfo(Pchar (Listbox1. Items[List Box1.ItemI ndex]), T, D); //Get BufferSize
GetMem(T, D);
GetUrlCacheEntryInfo(Pchar (Listbox1. Items[List Box1.ItemI ndex]), T, D);
Label1.Caption := 'Last time accessed: ' + FileTimeToDt(T^.LastAccess Time);
Label2.Caption := 'Last time syncronized: ' + FileTimeToDt(T^.LastSyncTi me);
Label3.Caption := 'Last time modified: ' + FileTimeToDt(T^.LastModifi edTime);
Label4.Caption := 'Expires: ' + FileTimeToDt(T^.ExpireTime );
Label5.Caption := 'Visited: ' + IntToStr(T^.dwHitRate);
Label6.Caption := 'URL: ' + Copy(T^.lpszSourceUrlName, Pos('@', T^.lpszSourceUrlName) + 1, MAX_PATH);
FreeMem(T, D);
end;
procedure TForm1.RetrieveBtnClick(Se nder: TObject);
var
T: PInternetCacheEntryInfo;
D: Cardinal;
H: THandle;
begin
D := 0;
H := FindFirstUrlCacheEntry(nil , nil, D); //Get bufferSize
GetMem(T, D);
if D > 0 then T^.dwStructSize := D;
H := FindFirstUrlCacheEntry(nil , T, D);
if GetLastError <> 0 then
repeat
if (T^.CacheEntryType = T^.CacheEntryType or URLHISTORY_CACHE_ENTRY) then
Listbox1.Items.Add(T^.lpsz SourceUrlN ame);
Freemem(T, D);
D := 0;
FindNextUrlCacheEntry(H, nil, D); //Get BufferSize
GetMem(T, D);
if D > 0 then T^.dwStructSize := D;
until not FindNextUrlCacheEntry(H, T, D);
FreeMem(T, D);
FindCloseUrlCache(H);
Listbox1.ItemIndex := 0;
Listbox1Click(sender);
end;
end.
above method should work on all.
you could also use the first method for nt and change reg string of first method to use it also for win9*.
interface
uses
WinInet, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
RetrieveBtn: TButton;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure ListBox1Click(Sender: TObject);
procedure RetrieveBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function GetUrlCacheEntryInfo(lpszU
PInternetCacheEntryInfo; var lpdwCacheEntryInfoBufferSi
function FindFirstUrlCacheEntry(lps
lpFirstCacheEntryInfo: PInternetCacheEntryInfo;
var lpdwFirstCacheEntryInfoBuf
function FindNextUrlCacheEntry(hEnu
PInternetCacheEntryInfo; var lpdwNextCacheEntryInfoBuff
var
Form1: TForm1;
implementation
{$R *.DFM}
const
URLHISTORY_CACHE_ENTRY = $00200000;
winetdll = 'wininet.dll';
function FindFirstUrlCacheEntry; external winetdll name 'FindFirstUrlCacheEntryA';
function FindNextUrlCacheEntry; external winetdll name 'FindNextUrlCacheEntryA';
function GetUrlCacheEntryInfo; external winetdll name 'GetUrlCacheEntryInfoA';
function FileTimeToDt(Ft: TFileTime): string;
var
l: Integer;
lft: TFileTime;
begin
FileTimeToLocalFiletime(Ft
if FileTimeToDosDateTime(lft,
result := DateTimeToStr(FiledateToDa
result := '';
end;
procedure TForm1.ListBox1Click(Sende
var
T: PInternetCacheEntryInfo;
D: Cardinal;
begin
D := 0;
GetUrlCacheEntryInfo(Pchar
GetMem(T, D);
GetUrlCacheEntryInfo(Pchar
Label1.Caption := 'Last time accessed: ' + FileTimeToDt(T^.LastAccess
Label2.Caption := 'Last time syncronized: ' + FileTimeToDt(T^.LastSyncTi
Label3.Caption := 'Last time modified: ' + FileTimeToDt(T^.LastModifi
Label4.Caption := 'Expires: ' + FileTimeToDt(T^.ExpireTime
Label5.Caption := 'Visited: ' + IntToStr(T^.dwHitRate);
Label6.Caption := 'URL: ' + Copy(T^.lpszSourceUrlName,
FreeMem(T, D);
end;
procedure TForm1.RetrieveBtnClick(Se
var
T: PInternetCacheEntryInfo;
D: Cardinal;
H: THandle;
begin
D := 0;
H := FindFirstUrlCacheEntry(nil
GetMem(T, D);
if D > 0 then T^.dwStructSize := D;
H := FindFirstUrlCacheEntry(nil
if GetLastError <> 0 then
repeat
if (T^.CacheEntryType = T^.CacheEntryType or URLHISTORY_CACHE_ENTRY) then
Listbox1.Items.Add(T^.lpsz
Freemem(T, D);
D := 0;
FindNextUrlCacheEntry(H, nil, D); //Get BufferSize
GetMem(T, D);
if D > 0 then T^.dwStructSize := D;
until not FindNextUrlCacheEntry(H, T, D);
FreeMem(T, D);
FindCloseUrlCache(H);
Listbox1.ItemIndex := 0;
Listbox1Click(sender);
end;
end.
above method should work on all.
you could also use the first method for nt and change reg string of first method to use it also for win9*.
ASKER
OK, Thank you very much
just delete everything in \windows\temporary internet files\
To clear the history urls you have
to clear some area in the registory
but i dont know where, ill check into it.
Later / Tommy