DeleteEntry
Use DeleteEntry(Url : String) to delete an entry in
the cache. Again you can use RetrieveEntries to search for
the files you want to delete.
The following sample shows how to use DeleteEntry to
delete all temporary internet files Including cookies and
clear the cache:
procedure
TForm1.Button1Click(Sender: TObject);
begin
IECache1.SearchPattern:=spAll;
Iecache1.RetrieveEntries(0);
end;
procedure TForm1.IECache1Entry(Sender:
TObject; var Cancel: Boolean);
begin
IECache1.DeleteEntry(IECache1.SourceUrlName);
end;
|
To delete all cookies and keep the rest of
the cache, you just set SearchPattern:=spCookies instead
of spAll.
In the following sample we want to delete
all entries added to the cache since the application was
started:
var
SessionStart: TDateTime;
procedure TForm1.FormCreate(Sender: TObject);
begin
SessionStart := Now;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if IECache1.FindFirstEntry(0) = S_OK
then begin
if
IECache1.EntryInfo.LastAccessTime >
SessionStart then
IECache1.DeleteEntry(IECache1.EntryInfo.SourceUrlName);
while IECache1.FindNextEntry =
S_OK do
if
IECache1.EntryInfo.LastAccessTime >
SessionStart then
IECache1.DeleteEntry(IECache1.EntryInfo.SourceUrlName);
end;
IECache1.CloseFindEntry;
end;
|
Return-values from DeleteEntry is
S_OK for succes, ERROR_FILE_NOT_FOUND or
ERROR_ACCESS_DENIED.