如何用程序删除win98下面的 C:/windows/History指定历史网址? 好急阿,请个位帮忙吧 (100分)

  • 主题发起人 主题发起人 hcai
  • 开始时间 开始时间
H

hcai

Unregistered / Unconfirmed
GUEST, unregistred user!
请高手帮忙:如何用程序删除win98下面的 C:/windows/History指定历史网址? 好急阿
 
注册表,查找,然后删除
 
2K:
C:/Documents and Settings/用户名/Local Settings/History

98:
C:/windows/History
 
独门秘籍:)
procedure TzypNeoForm.btnDeltempClick(Sender: TObject);
var
lpEntryInfo : PInternetCacheEntryInfo;
hCacheDir : LongWord;
dwEntrySize : LongWord;
dwLastError : LongWord;
Begin
dwEntrySize := 0;
FindFirstUrlCacheEntry( NIL, TInternetCacheEntryInfo( NIL^ ), dwEntrySize );
GetMem( lpEntryInfo, dwEntrySize );
hCacheDir := FindFirstUrlCacheEntry( NIL, lpEntryInfo^, dwEntrySize );
If ( hCacheDir <> 0 ) Then
DeleteUrlCacheEntry( lpEntryInfo^.lpszSourceUrlName );
FreeMem( lpEntryInfo );
Repeat
dwEntrySize := 0;
FindNextUrlCacheEntry( hCacheDir, TInternetCacheEntryInfo( NIL^ ), dwEntrySize );
dwLastError := GetLastError();
If ( GetLastError = ERROR_INSUFFICIENT_BUFFER ) Then Begin
GetMem( lpEntryInfo, dwEntrySize );
If ( FindNextUrlCacheEntry( hCacheDir, lpEntryInfo^, dwEntrySize ) ) Then
DeleteUrlCacheEntry( lpEntryInfo^.lpszSourceUrlName );
FreeMem(lpEntryInfo);
End;
Until ( dwLastError = ERROR_NO_MORE_ITEMS );
Application.MessageBox('清除IE临时文件成功!','网络工具箱', MB_ICONINFORMATION+MB_OK)
end;
 
wql那种直接删文件的办法应该可以
 
其实好多的程序只要自己考虑一下就会有简单的办法解决了,
在注册表里查找相关的健值然后删除,,
删除文件的方法也可以,
应该的呵呵呵没有使用过
 
工具,Internet选项中有的什么都可以帮你清除的,按它的提示干就行了。
 
谢谢各位,但我要写成程序,请各位帮忙阿。
 
uses Wininet
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;


procedure ClearIEHistory;

implementation
//清楚IE历史记录
procedure ClearIEHistory; //调用
const
CLSID_CUrlHistory: TGUID = '{3C374A40-BAE4-11CF-BF7D-00AA006946EE}';
var
IEHistory:IUrlHistoryStg2;
begin
IEHistory:=CreateComObject(CLSID_CUrlHistory) as IUrlHistoryStg2;
IEHistory.ClearHistory;
end;

 
绝对能用。
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Activex, Comobj, StdCtrls, ComCtrls, Grids;

const

STATURL_QUERYFLAG_ISCACHED = $00010000;
STATURL_QUERYFLAG_NOURL = $00020000;
STATURL_QUERYFLAG_NOTITLE = $00040000;
STATURL_QUERYFLAG_TOPLEVEL = $00080000;

STATURLFLAG_ISCACHED = $00000001;
STATURLFLAG_ISTOPLEVEL = $00000002;


IID_IEnumStatUrl: TGUID = (D1: $3C374A42; D2: $BAE4; D3: $11CF; D4: ($BF, $7D, $00, $AA, $00, $69, $46, $EE));
IID_IUrlHistoryStg: TGUID = (D1: $3C374A41; D2: $BAE4; D3: $11CF; D4: ($BF, $7D, $00, $AA, $00, $69, $46, $EE));
IID_IUrlHistoryStg2: TGUID = (D1: $AFA0DC11; D2: $C313; D3: $831A; D4: ($83, $1A, $00, $C0, $4F, $D5, $AE, $38));
IID_IUrlHistoryNotify: TGUID = (D1: $BC40BEC1; D2: $C493; D3: $11D0; D4: ($83, $1B, $00, $C0, $4F, $D5, $AE, $38));

SID_IEnumStatUrl = '{3C374A42-BAE4-11CF-BF7D-00AA006946EE}';
SID_IUrlHistoryStg = '{3C374A41-BAE4-11CF-BF7D-00AA006946EE}';
SID_IUrlHistoryStg2 = '{AFA0DC11-C313-11d0-831A-00C04FD5AE38}';
SID_IURLHistoryNotify = '{BC40BEC1-C493-11d0-831B-00C04FD5AE38}';
CLSID_CUrlHistory: TGUID = '{3C374A40-BAE4-11CF-BF7D-00AA006946EE}';


type
STATURL = record
cbSize: DWORD;
pwcsUrl: DWORD;
pwcsTitle: DWORD;
ftLastVisited: FILETIME;
ftLastUpdated: FILETIME;
ftExpires: FILETIME;
dwFlags: DWORD;
end;


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;

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: STATURL): HResult; stdcall;
function BindToObject(pocsUrl: PWideChar; var riid: TIID; out ppvOut: Pointer): HResult; stdcall;
function EnumUrls(out ppenum: IEnumSTATURL): HResult; stdcall;
end;

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;

IUrlHistoryNotify = interface(IOleCommandTarget)
['{BC40BEC1-C493-11d0-831B-00C04FD5AE38}']
end;



TForm1 = class(TForm)
StringGrid1: TStringGrid;
RetrieveBtn: TButton;
ClearBtn: TButton;
procedure RetrieveBtnClick(Sender: TObject);
procedure ClearBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
I: IUrlHistoryStg2;

implementation

{$R *.DFM}


function FileTimeToDt(Ft: TFileTime): TDateTime;
var
l: Integer;
lft: TFileTime;
begin
FileTimeToLocalFiletime(Ft, lft);
if FileTimeToDosDateTime(lft, Longrec(l).Hi, Longrec(l).Lo) then
result := FiledateToDatetime(l) else
result := 0;
end;


procedure TForm1.RetrieveBtnClick(Sender: TObject);//在STRINGGRID中显示历史记录
var
r: Staturl;
Enum: IEnumStatUrl;
X: Integer;
Row: Integer;
begin
StringGrid1.Cells[0, 0] := 'Last Visited';
StringGrid1.Cells[1, 0] := 'Title';
StringGrid1.Cells[2, 0] := 'Url';
StringGrid1.Cells[3, 0] := 'Last Updated';
StringGrid1.Cells[4, 0] := 'Expires';
Row := 0;
I := CreateComObject(ClsId_CUrlHistory) as IUrlHistoryStg2;
I.EnumUrls(Enum);
Enum.SetFilter('http://', 0);
while enum.next(1, r, @X) = S_OK do begin
Inc(Row);
StringGrid1.RowCount := Row + 1;
Stringgrid1.Cells[0, Row] := DateTimeToStr(FileTimeToDt(r.ftLastVisited));
Stringgrid1.Cells[1, Row] := PWidechar(Pointer(r.pwcsTitle));
Stringgrid1.Cells[2, Row] := PWidechar(Pointer(r.pwcsUrl));
Stringgrid1.Cells[3, Row] := DateTimeToStr(FileTimeToDt(r.ftLastUpdated));
Stringgrid1.Cells[4, Row] := DateTimeToStr(FileTimeToDt(r.ftExpires));
end;
end;

procedure TForm1.ClearBtnClick(Sender: TObject);//清空历史记录
begin
I.ClearHistory;
end;

end.
 
TO zhangkan:
谢谢你的回复,请问删除过去指定的历史网址吗,在IE地址栏不要显示已经删除的网址
 
要删除地址栏的网址可以试试下面的代码
procedure TForm1.Button1Click(Sender: TObject);
var
MyReg:TRegistry;
begin
try
MyReg:=Tregistry.Create ;
with MyReg do
try
RootKey := HKEY_CURRENT_USER;
OpenKey( '/Software/Microsoft/Internet Explorer', TRUE );
deletekey('TypedUrls');
createkey('TypedUrls');
finally
myreg.free;
end;
showmessage('IE地址栏网址清空完毕!,需重新打开IE后有效!');
except
showmessage('IE地址栏网址无法清空,请重启后再试!');
end;
end;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部