twebbrowser 问题

zoujianqing 2009-01-07 06:17:35
如果在delphi中实现 使用twebbrowser 不读缓存,而是直接从网页上下载啊
急!!!
...全文
97 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
无条件为你 2009-01-08
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}


uses WinINet;

procedure ClearTempInternetFiles(RemCookies: boolean);
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord (*Handle*);
dwEntrySize, dwLastError: LongWord;
begin
//Get size of first entry in dwEntrySize
dwEntrySize := 0;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);

//Create structure that can hold entry
GetMem(lpEntryInfo, dwEntrySize);
try
//Get first cache entry and handle to retrieve next entry, output url
hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir = 0 then
exit;

if (hCacheDir <> 0) and
((lpEntryInfo^.CacheEntryType and NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY) then
begin
if ((lpEntryInfo^.CacheEntryType and COOKIE_CACHE_ENTRY) = 0) or RemCookies then
begin
if FileExists(string(lpEntryInfo^.lpszLocalFileName)) then
DeleteFile(string(lpEntryInfo^.lpszLocalFileName)); //delete file

DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
end;
end;
finally
//free structure
FreeMem(lpEntryInfo);
end;

//retrieve all subsequent entries
repeat
dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
dwLastError := GetLastError();

if dwLastError = ERROR_INSUFFICIENT_BUFFER then begin
GetMem(lpEntryInfo, dwEntrySize);
try
if FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) then begin
if ((lpEntryInfo^.CacheEntryType and NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY) then
begin
if ((lpEntryInfo^.CacheEntryType and COOKIE_CACHE_ENTRY) = 0) or RemCookies then
begin
if FileExists(string(lpEntryInfo^.lpszLocalFileName)) then
DeleteFile(string(lpEntryInfo^.lpszLocalFileName)); //delete file

DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
end;
end;
end else
exit;
finally
FreeMem(lpEntryInfo);
end;
end else
exit;
until dwLastError = ERROR_NO_MORE_ITEMS;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Screen.Cursor := crHourGlass;
try
ClearTempInternetFiles(true);
finally
Screen.Cursor := crDefault;
end;
end;

end.
无条件为你 2009-01-08
  • 打赏
  • 举报
回复
每次加载时先清掉缓存即可。给分有些少,就只回答你这么多。

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧