1.添加网页到收藏夹的函数:
procedure AddURL(Folder, Url, Title: string);
var
MyUrlFile: TextFile;
begin
if Folder[Length(Folder)] <> '\' then Folder := Folder + '\';
if not DirectoryExists(Folder) then ForceDirectories(Folder);
try
AssignFile(MyUrlFile, Folder + title + '.url');
Rewrite(MyUrlFile);
WriteLn(MyUrlFile, '[InternetShortcut]');
WriteLn(MyUrlFile, 'URL=' + url);
finally
Closefile(MyUrlFile);
end;
end;

2、清理IE缓存的代码(亲测可用)

 ShellExecute(,'open','rundll32.exe','inetcpl.cpl,ClearMyTracksByProcess 8',nil,); //IE缓存

ShellExecute(,'open','rundll32.exe','inetcpl.cpl,ClearMyTracksByProcess 2',nil,); //IE cookies

ShellExecute(,'open','rundll32.exe','inetcpl.cpl,ClearMyTracksByProcess 1',nil,); //IE history

ShellExecute(,'open','rundll32.exe','inetcpl.cpl,ClearMyTracksByProcess 16',nil,); //form

ShellExecute(,'open','rundll32.exe','inetcpl.cpl,ClearMyTracksByProcess 32',nil,); //auto save pass

ShellExecute(,'open','rundll32.exe','inetcpl.cpl,ClearMyTracksByProcess 255',nil,); //all

ShellExecute(,'open','rundll32.exe','inetcpl.cpl,ClearMyTracksByProcess 4351',nil,); //all & addons

3、清理IE缓存的类 (好像清理不了 )

unit uCleanCookie;

interface
uses
Registry, ShellApi, WinInet, ShlObj, ComObj, Windows, Forms, SysUtils, shdocvw; type
TIECookie = class
private public
procedure DelRegCache;
function GetCookiesFolder: string;
procedure DelCookie;
procedure DelHistory;
function ClearIEHistory:integer;
published end;
type
TSTATURL = record
cbSize: DWORD;
pwcsUrl: DWORD;
pwcsTitle: DWORD;
ftLastVisited: FILETIME;
ftLastUpdated: FILETIME;
ftExpires: FILETIME;
dwFlags: DWORD;
end; type
IEnumSTATURL = interface(IUnknown)
['{3C374A42-BAE4-11CF-BF7D-00AA006946EE}']
function Next(celt: Integer; out elt; pceltFetched: PLongint): HRESULT; stdcall;
function Skip(celt: Longint): HRESULT; stdcall;
function Reset: HResult; stdcall;
function Clone(out ppenum: IEnumSTATURL): HResult; stdcall;
function SetFilter(poszFilter: PWideChar; dwFlags: DWORD): HResult; stdcall;
end; type
IUrlHistoryStg = interface(IUnknown)
['{3C374A41-BAE4-11CF-BF7D-00AA006946EE}']
function AddUrl(pocsUrl: PWideChar; pocsTitle: PWideChar; dwFlags: Integer): HResult; stdcall;
function DeleteUrl(pocsUrl: PWideChar; dwFlags: Integer): HResult; stdcall;
function QueryUrl(pocsUrl: PWideChar; dwFlags: Integer; var lpSTATURL: TSTATURL): HResult; stdcall;
function BindToObject(pocsUrl: PWideChar; var riid: TGUID; out ppvOut: Pointer): HResult; stdcall;
function EnumUrls(out ppenum: IEnumSTATURL): HResult; stdcall;
end; type
IUrlHistoryStg2 = interface(IUrlHistoryStg)
['{AFA0DC11-C313-11D0-831A-00C04FD5AE38}']
function AddUrlAndNotify(pocsUrl: PWideChar; pocsTitle: PWideChar; dwFlags: Integer;
fWriteHistory: Integer; var poctNotify: Pointer;
const punkISFolder: IUnknown): HResult; stdcall;
function ClearHistory: HResult; stdcall;
end;
implementation
{ TIECookie } function TIECookie.ClearIEHistory: integer;
const
CLSID_CUrlHistory: TGUID = '{3C374A40-BAE4-11CF-BF7D-00AA006946EE}';
var
IEHistory:IUrlHistoryStg2;
begin
IEHistory:=CreateComObject(CLSID_CUrlHistory) as IUrlHistoryStg2;
IEHistory.ClearHistory; end; procedure TIECookie.DelCookie;
var
dir: string;
begin
try
InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION, nil, );
dir := GetCookiesFolder;
//ShellDeleteFile(dir+'\*.txt'+#0); //网上很多代码这里没有加最后的#0,在xp下经测试会报错
except
abort;
end;
end; procedure TIECookie.DelHistory;
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord;
dwEntrySize, dwLastError: LongWord;
begin
try
dwEntrySize := ;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize);
hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> then
DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
FreeMem(lpEntryInfo);
repeat
dwEntrySize := ;
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);
except
abort;
end; end; procedure TIECookie.DelRegCache;
var
reg: TRegistry;
begin
reg := Tregistry.create;
reg.RootKey := HKEY_CURRENT_USER;
reg.DeleteKey('Software\Microsoft\Internet Explorer\TypedURLs');
reg.Free; end; function TIECookie.GetCookiesFolder: string;
var
pidl: pItemIDList;
buffer: array[..] 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), ); {记录清零}
with FOS do
begin
wFunc := FO_DELETE; //删除
pFrom := PChar(sFileName);
fFlags := FOF_NOCONFIRMATION;
end;
Result := (SHFileOperation(FOS) = ); end; end. 调用方法: procedure TForm2.FormCreate(Sender: TObject); begin
TClean:=TIECookie.Create;
try
TClean.DelRegCache;//清理注册表
TClean.DelCookie; //删除cookies(ie缓冲文件夹下面cookies文件)
TClean.DelHistory; //删除历史记录(ie缓冲文件夹下所有文件)
//C:\Documents and Settings\用户名\Local Settings\Temporary Internet Files
TClean.ClearIEHistory; //补充删除网页历史
TClean.Free;
except
abort;
end;
end;

有关IE的操作(收藏夹,清理缓存等)的更多相关文章

  1. 360浏览器 收藏夹 ico 缓存 目录

    C:\Users\Administrator\AppData\Roaming\360se6\apps\data\users\default\data\ico

  2. 骚操作!曾经爱过!用 Python 清理收藏夹里已失效的网站

    前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 小詹&有乔木 PS:如有需要Python学习资料的小伙伴可 ...

  3. iOS之 清理缓存

    作为一个开发者,对于缓存的清理也是理所应当的需要的.这次就简单的谈一下iOS中对于缓存的清理方法. 我们清理缓存通常是在这三种方式下进行的: (1)项目中的清理缓存按钮 (2)点击退出app按钮时清理 ...

  4. Django Web开发【3】创建网络收藏夹

    这一节我们将继续一个创建网络收藏夹应用,并学习视图.模型以及模板的处理过程. Django是一个MVC开发框架,但是它的控制器对应的为view,而视图对应为模板(template),模型对应model ...

  5. (转载) 清理缓存 IPackageStatsObserver

    清理缓存 IPackageStatsObserver 2016-04-10 13:40 2288人阅读 评论(0) 收藏 举报  分类: android(59)  版权声明:本文为博主原创文章,未经博 ...

  6. 基于Metronic的Bootstrap开发框架经验总结(13)--页面链接收藏夹功能的实现2(利用Sortable进行拖动排序)

    在上篇随笔<基于Metronic的Bootstrap开发框架经验总结(12)--页面链接收藏夹功能的实现>上,我介绍了链接收藏夹功能的实现,以及对收藏记录的排序处理.该篇随笔主要使用功能按 ...

  7. 修复 Windows7 资源管理器左侧收藏夹无法展开问题

    相信大家在网上搜多到的解决办法大多数都是修改注册表,但是这个办法多数是无效的 1.运行regedit 2.展开到HKEY_CLASSES_ROOT\lnkfile 3.添加一个字符串值:IsShort ...

  8. 基于Metronic的Bootstrap开发框架经验总结(12)--页面链接收藏夹功能的实现

    在一个系统里面,往往有很多菜单项目,每个菜单项对应一个页面,一般用户只需要用到一些常用的功能,如果每次都需要去各个层次的菜单里面去找对应的功能,那确实有点繁琐.特别是在菜单繁多,而客户又对系统整体不熟 ...

  9. 设为首页 添加到收藏夹 (share)

    设为首页,添加到收藏夹 分享自:http://my.oschina.net/lyx2012/blog/60036 设为首页 和 收藏本站js代码 兼容IE,chrome,ff <script t ...

随机推荐

  1. JSON.stringify

    $(document).ready(function (){var things =[{ id:1, color:'yellow'},{ id:2, color:'blue'},{ id:3, col ...

  2. ASP.net 探针

    <%@ Page Language="JScript" ContentType="text/html" ResponseEncoding="gb ...

  3. Redis集群创建报错

    Redis集群环境:och163/och164/och165 在执行如下脚本时报错: ./src/redis-trib.rb create 10.1.253.163: 10.1.253.164: 10 ...

  4. 【Unity Shaders】学习笔记——SurfaceShader(四)用纹理改善漫反射

    [Unity Shaders]学习笔记——SurfaceShader(四)用纹理改善漫反射 转载请注明出处:http://www.cnblogs.com/-867259206/p/5603368.ht ...

  5. x86_64 Ubuntu 14.04 LST安装gcc4.1.2 转载

    由于编译源码软件需要用到gcc4.1.2版本,但是本机已经安装有gcc4.8.4,下载gcc4.1.2源码编译总会出现运行找不到库文件错误,或者i386和x86_64不兼容问题,在http://ask ...

  6. java.lang.NumberFormatException: For input string: "Y"

    nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.  ...

  7. tar: 从成员名中删除开头的“/”

    在压缩文件时,当后面的备份目录使用绝对路径时,会出现: tar zcvf   /usr/OutFile.tar.gz  /data/CTest tar: 从成员名中删除开头的“/” 此时,对tar增加 ...

  8. Digest [IAB_SRI_Online_Advertising_Effectiveness]

    http://www.pwc.com/en_GX/gx/entertainment-media/pdf/IAB_SRI_Online_Advertising_Effectiveness_v3.pdf

  9. 匿名管道 远程cmd

    管道是单向的,传送数据的方向是固定的,所以互相通信需要两个管道. STARTUPINFO si; ZeroMemory(&si,sizeof(si)); si.dwFlags = STARTF ...

  10. oracle:触发器,自治事务 trigger

    create or replace trigger TRI_FC83_INSERT before insert ON FC83 FOR EACH ROW declare PRAGMA AUTONOMO ...