我今年年初写的程序:Win98se\Win2K server + Delphi 7IE地址栏中//你可以导入一个列表里边自己选择删除什么 var tempList:TStringList; i:integer; begin reg:=TRegistry.Create; try reg.RootKey:=HKEY_CURRENT_USER; if reg.OpenKey('Software\Microsoft\Internet Explorer\TypedURLs',false) then begin tempList:=TStringList.Create; try reg.GetValueNames(tempList); for i:=0 to tempList.Count-1 do reg.DeleteValue(tempList.Strings[i]); addurlLb.Items.Clear; freshaddFsb.Enabled:=false; deladdressFsb.Enabled:=false; delallFsb.Enabled:=false; finally tempList.Free; end; end; finally reg.Free; end;清除历史记录: type TSTATURL=record cbSize:DWORD; pwcsUrl:DWORD; pwcsTitle:DWORD; ftlastVisited:FILETIME; ftlastUpdated:FILETIME; ftExpirts: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; //***************************************************************function iehistoryClear:integer; const CLSID_CUrlHistory:TGUID='{3C374A40-BAE4-11CF-BF7D-00AA006946EE}'; var IeHistory:IUrlHistoryStg2; begin IeHistory:=CreateComobject(CLSID_CUrlHistory) as IUrlHistoryStg2; IeHistory.ClearHistory; IeHistory._Release; result:=S_OK; end;
uses wininet;procedure TForm1.Button1Click(Sender: TObject); var cache_info:PInternetCacheEntryInfo; cbSizeOf_Cache_info:dword; hw:hwnd; buf:tstrings; begin // buf:=tstringlist.Create; new(cache_info); hw:=FindFirstUrlCacheEntryEx(nil,0,NORMAL_CACHE_ENTRY or URLHISTORY_CACHE_ENTRY,0,cache_info,@cbSizeOf_Cache_info,nil,nil,nil); if hw<>0 then begin DeleteUrlCacheEntry(cache_info.lpszSourceUrlName); // buf.Add(cache_info.lpszSourceUrlName); while FindNextUrlCacheEntryEx(hw,cache_info,@cbSizeOf_Cache_info,nil,nil,nil) do // buf.Add(cache_info.lpszSourceUrlName); DeleteUrlCacheEntry(cache_info.lpszSourceUrlName); end; FindCloseUrlCache(hw); dispose(cache_info); // showmessage(buf.Text); // buf.Free; end;
var
tempList:TStringList;
i:integer;
begin
reg:=TRegistry.Create;
try
reg.RootKey:=HKEY_CURRENT_USER;
if reg.OpenKey('Software\Microsoft\Internet Explorer\TypedURLs',false) then
begin
tempList:=TStringList.Create;
try
reg.GetValueNames(tempList);
for i:=0 to tempList.Count-1 do
reg.DeleteValue(tempList.Strings[i]);
addurlLb.Items.Clear; freshaddFsb.Enabled:=false;
deladdressFsb.Enabled:=false;
delallFsb.Enabled:=false;
finally
tempList.Free;
end;
end;
finally
reg.Free;
end;清除历史记录:
type
TSTATURL=record
cbSize:DWORD;
pwcsUrl:DWORD;
pwcsTitle:DWORD;
ftlastVisited:FILETIME;
ftlastUpdated:FILETIME;
ftExpirts: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;
//***************************************************************function iehistoryClear:integer;
const
CLSID_CUrlHistory:TGUID='{3C374A40-BAE4-11CF-BF7D-00AA006946EE}';
var
IeHistory:IUrlHistoryStg2;
begin
IeHistory:=CreateComobject(CLSID_CUrlHistory) as IUrlHistoryStg2;
IeHistory.ClearHistory;
IeHistory._Release;
result:=S_OK;
end;
var
cache_info:PInternetCacheEntryInfo;
cbSizeOf_Cache_info:dword;
hw:hwnd;
buf:tstrings;
begin
// buf:=tstringlist.Create;
new(cache_info);
hw:=FindFirstUrlCacheEntryEx(nil,0,NORMAL_CACHE_ENTRY or URLHISTORY_CACHE_ENTRY,0,cache_info,@cbSizeOf_Cache_info,nil,nil,nil);
if hw<>0 then
begin
DeleteUrlCacheEntry(cache_info.lpszSourceUrlName);
// buf.Add(cache_info.lpszSourceUrlName);
while FindNextUrlCacheEntryEx(hw,cache_info,@cbSizeOf_Cache_info,nil,nil,nil) do
// buf.Add(cache_info.lpszSourceUrlName);
DeleteUrlCacheEntry(cache_info.lpszSourceUrlName);
end;
FindCloseUrlCache(hw);
dispose(cache_info);
// showmessage(buf.Text);
// buf.Free;
end;