Transfer from Http://hi.baidu.com/delphidiary
Transfer from http://blog.sina.com.cn/s/blog_725fb194010150jh.html
add several PAS units in front of//
uses Registry,shellapi, WinInet,shlobj, comobj ;
======================================== Delete cookies==========================procedureDelregcache;varReg:tregistry;beginReg:=tregistry.create; Reg. Rootkey:=HKEY_CURRENT_USER; Reg. DeleteKey ('software\microsoft\internet Explorer\TypedURLs'); Reg. Free;End;functionGetcookiesfolder:string;varpidl:pitemidlist; Buffer:Array[0..255] ofChar;beginshgetspecialfolderlocation (Application. Handle, Csidl_cookies, pidl); SHGetPathFromIDList (pidl, buffer); Result:=Strpas (buffer);End;functionShelldeletefile (sfilename:string): Boolean;varfos:tshfileopstruct;beginFillchar (FOS, SizeOf (FOS),0);{Record 0} withFos Do beginWfunc:= fo_delete;//Delete pfrom:=PChar (sFileName); Fflags:=fof_noconfirmation; End; Result:= (SHFileOperation (FOS) =0);End;//Delete CookiesprocedureDelcookie;vardir:string;begin TryInternetSetOption (Nil, Internet_option_end_browser_session,Nil,0); Dir:=Getcookiesfolder; Shelldeletefile (dir+'\*.txt'+#0); There's a lot of code on the web here without the last #0, the test will be error after XPexceptabort; End;End;======================================== Delete cookies=========================
USES mshtml
procedureTform1.webbrowser1documentcomplete (asender:tobject;2 ConstPdisp:idispatch;varurl:olevariant);3 var4 I:integer;5 iall:ihtmlelement;6 begin7 ifWebbrowser1.application = pdisp Then8 begin9 memo1.clear;Ten ifAssigned (webbrowser1.document) Then One begin AIall: =(webbrowser1.document as IHTMLDocument2). Body; - whileIall.parentelement <>Nil Do - begin theIall: =iall.parentelement; - End; -Memo1.text: = memo1.text+iall.outerhtml; - End; + End; - End;