如何清空IE缓存文件夹(200分)

  • 主题发起人 主题发起人 fima
  • 开始时间 开始时间
F

fima

Unregistered / Unconfirmed
GUEST, unregistred user!
我在别的地方找的来个方法,一个使用ShellAPI做,但是好似不能实现

另外一个方法如下:

procedure DeleteIECache; //清理IE缓存
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord;
dwEntrySize: LongWord;
cachefile: string;
i: integer;
cancheqqlist: TStringList;
begin
cancheqqlist := TStringList.Create;
cancheqqlist.Clear;
dwEntrySize := 0;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize);
if dwEntrySize > 0 then
lpEntryInfo^.dwStructSize := dwEntrySize;
hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> 0 then
begin
repeat
if (lpEntryInfo^.CacheEntryType) and (NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY then
cachefile := pchar(lpEntryInfo^.lpszSourceUrlName);
if pos('Delphibbs.com', cachefile) > 0 then //符合条件的清除 cancheqqlist.Add(cachefile);
for i := 0 to cancheqqlist.Count - 1 do
DeleteUrlCacheEntry(pchar(cancheqqlist.Strings)); //执行删除
FreeMem(lpEntryInfo, dwEntrySize);
dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize);
if dwEntrySize > 0 then
lpEntryInfo^.dwStructSize := dwEntrySize;
until not FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize);
end;
FreeMem(lpEntryInfo, dwEntrySize);
FindCloseUrlCache(hCacheDir);
cancheqqlist.Free;
end;


这个能实现但是速度很慢,基本上5000零时个文件要卡30秒左右,这样就没有什么意义了 = =

我看到别人的程序删除的时候一点也不卡....不知道怎么实现的,有哪位高人能够告知小弟,不胜感激

还有,这个Temporary Internet Files文件夹个结构有些奇怪,有时会出现二级目录,但是在窗口下面是看不到二级目录的,而用遍历的方法然后showmessage却能看到二级目录....真不明白
 
是有点慢吧,我看直接在IE中操作也比较慢啊。
 
直接删掉整个目录就会很快,呵呵,如果用汇编更快,只要改几个磁盘地址就行。不过这都是高人做的事。我要做的事是来学习的。
 
LS的看看这个文件夹能不能删除 = =
如果用遍历的方法,这个破文件夹怎么遍历?好似不是普通文件夹...
 
用线程方式,基本上感觉不出来占用时间了.
 
LS说得怎么实现? = =
 
1.建线程
unit UmThread;

interface

uses Classes, WinInet;

type
TCleanHistory = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
constructor create;
end;

implementation

{ TCleanHistory }

procedure DeleteIECache; //清理IE缓存
begin
.....
end;

procedure TCleanHistory.Execute;
begin
repeat
DeleteIECache;
Suspend;
until false;
end;

constructor TCleanHistory.create;
begin
inherited create(true);
end;

end.

2.主程序
...
uses UmThread;

var
CleanHistory:TCleanHistory;

procedure TFormMain.FormCreate(Sender: TObject);
begin
CleanHistory:=TCleanHistory.create;
CleanHistory.FreeOnTerminate:=True;
.....
end;

procedure TFormMain.Button1Click(Sender: TObject);
begin
CleanHistory.Resume;
end;

调试时,退出程序奇慢;我也想知道问题出在哪了.
 

Similar threads

后退
顶部