能用程序的方法调用IE工具栏的[删除Cookies]功能吗? ( 积分: 100 )

  • 主题发起人 主题发起人 龙卷风2005
  • 开始时间 开始时间

龙卷风2005

Unregistered / Unconfirmed
GUEST, unregistred user!
有些网站总是弹出对话框或自动连接到不喜欢的网址,请问能用程序的方法调用IE中的工具直接删除Cookies吗?
 
有些网站总是弹出对话框或自动连接到不喜欢的网址,请问能用程序的方法调用IE中的工具直接删除Cookies吗?
 
帮楼主顶一下,我也正在想解决这个问题,我再出100分,不给不是人.
 
那位大富翁出来说说啊?
难道这个问题很难吗?
 
删除历史记录

procedure DelHistory;
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord ;
dwEntrySize, dwLastError: LongWord;
begin
dwEntrySize := 0;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize);

hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> 0 then
DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
FreeMem(lpEntryInfo);

repeat
dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^),
dwEntrySize);
dwLastError := GetLastError();
if dwLastError = ERROR_INSUFFICIENT_BUFFER then //如果成功
begin
GetMem(lpEntryInfo, dwEntrySize); {分配dwEntrySize字节的内存}
if FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) then
DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
FreeMem(lpEntryInfo);
end;
until (dwLastError = ERROR_NO_MORE_ITEMS);
end;

procedure DelRegCache;
var
reg:TRegistry;
begin
reg:=Tregistry.create;
reg.RootKey:=HKEY_CURRENT_USER;
reg.DeleteKey('Software/Microsoft/Internet Explorer/TypedURLs');
reg.Free;
end;

function GetCookiesFolder:string;
var
pidl:pItemIDList;
buffer:array [ 0..255 ] of char ;
begin
SHGetSpecialFolderLocation(
application.Handle , CSIDL_COOKIES, pidl);

SHGetPathFromIDList(pidl, buffer);
result:=strpas(buffer);
end;

function ShellDeleteFile(sFileName: string): Boolean;
var
FOS: TSHFileOpStruct;
begin
FillChar(FOS, SizeOf(FOS), 0); {记录清零}
with FOS do
begin
wFunc := FO_DELETE;//删除
pFrom := PChar(sFileName);
fFlags := FOF_NOCONFIRMATION;
end;
Result := (SHFileOperation(FOS) = 0);
end;

procedure DelCookie;
var
dir:string;
begin
InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION, nil, 0);
dir:=GetCookiesFolder;
ShellDeleteFile(dir+'/*.txt');
end;
 
to:zhuangbx
我用过这段代吗,如果保持该程序不变则可以删除;
但是,当我将其放入WebBrowser所写的程序里调用时会弹出[无法读文件:无法读源文件或磁盘],请问我该如何做呢?分我肯定会给你的~~~
 
后退
顶部