Written on 2009年1月8日 @ 11:21 | by spirit | Tags: delphi  源码   | 浏览:

    像清理电脑垃圾之类的电脑优化软件中都有清除cookies、ie缓存的功能,Delphi利用下面的函数即可实现清除IE的缓存:

 


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; 

//删除cookies 
procedure DelCookie; 
var 
       dir:string; 
begin 
      try 
       InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION, nil, 0); 
       dir:=GetCookiesFolder;
       ShellDeleteFile(dir+'\*.txt'+#0);
       except
       abort; 
      end; 

end; 


若转载请注明出处: Spirit's Home
本文地址: http://www.7788sky.cn/post/celphi_delete_cookies.html
  1. 0 Response to “Delphi删除cookies 函数”

Post a Comment

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。