求稳定的删COOKIE代码!(200)

  • 主题发起人 主题发起人 linchhero
  • 开始时间 开始时间
L

linchhero

Unregistered / Unconfirmed
GUEST, unregistred user!
我在网上找到一个DELPHI删COOKIE代码,效果不错,就是不稳定. 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 try InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION , nil, 0); ///有时候断网后,执行到这个地方,卡住 dir:=GetCookiesFolder; ShellDeleteFile(dir+'/*.txt'+#0); except on e:exception do Abort; end; end; InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION , nil, 0); 问题就在这一句代码里面,有时候就执行到这一句就卡住了,用try except do end; 捕捉不到错误.
 
后退
顶部