查看完整版本: delphi写的IE地址栏选择性清理助手代码

梦难留 2008-4-19 04:24

delphi写的IE地址栏选择性清理助手代码

[font=Verdana]IE地址栏会记录访问过的URL地址记录,如何选择性的清理这些地址呢?如通过注册表可以,所以这里用delphi写了个IE地址栏清理助手,下面是完整[url=http://www.xuedelphi.cn/][color=#810081]代码[/color][/url]:[/font]
[font=Verdana][font=Verdana]unit Unit1;[/font]
[font=Verdana]interface[/font]
[font=Verdana]uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, [url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]s,
  Dialogs,Registry, ComCtrls, ImgList, ExtCtrls, StdCtrls, Menus,shellapi,
  WinSkinData;[/font]
[font=Verdana]type
  T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1 = class(T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url])
    ListView1: TListView;
    ImageList1: TImageList;
    StatusBar1: TStatusBar;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    SkinData1: TSkinData;
    delphi1: TMenuItem;
    [url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] [url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]Create(Sender: TObject);
    [url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] ListView1Click(Sender: TObject);
    [url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] N1Click(Sender: TObject);
    [url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] N3Click(Sender: TObject);
    [url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] N4Click(Sender: TObject);
    [url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] N2Click(Sender: TObject);
    [url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] delphi1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;[/font]
[font=Verdana]var
  [url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1: T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1;
   reg:Tregistry;
implementation[/font]
[font=Verdana]{$R *.dfm}[/font]
[font=Verdana][url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1.[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]Create(Sender: TObject);
var
Val:TStringList;
i:integer;
begin
   reg:=Tregistry.Create;
   Val:=TStringList.Create;
   reg.RootKey:=HKEY_LOCAL_MACHINE;
   listview1.Clear;
   if reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',false) then
   begin
     Reg.GetValueNames(val);[/font]
[font=Verdana]     for i:=0 to val.Count-1 do
     begin
        listview1.Items.Add.Caption:=reg.ReadString(val.Strings[i])
     end;
   end;
   StatusBar1.Panels[0].Text:='请选择目标URL地址,使用鼠标右键操作!';
end;[/font]
[font=Verdana][url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1.ListView1Click(Sender: TObject);
begin
       if  listview1.SelCount<>0 then
  StatusBar1.Panels[0].Text:=listview1.Selected.Caption
  else
   StatusBar1.Panels[0].Text:='请选择目标URL地址!';
end;[/font]
[font=Verdana][url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1.N1Click(Sender: TObject);
var
Val:TStringList;
i:integer;
begin
  if listview1.SelCount<>0 then
  reg:=Tregistry.Create;
   Val:=TStringList.Create;
   reg.RootKey:=HKEY_LOCAL_MACHINE;
   if reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',false) then
   begin
     Reg.GetValueNames(val);
     for i:=0 to listview1.Items.Count-1 do
     begin
     if listview1.Items[i].Selected then[/font]
[font=Verdana]      begin
       reg.DeleteValue(val.Strings[i]);
      end;
     end;
     listview1.DeleteSelected;
   end
   else
     StatusBar1.Panels[0].Text:='请选择要删除的目标URL地址!';
end;[/font]
[font=Verdana][url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1.N3Click(Sender: TObject);
var
Val:TStringList;
i:integer;
begin
   reg:=Tregistry.Create;
   Val:=TStringList.Create;
   reg.RootKey:=HKEY_LOCAL_MACHINE;
   listview1.Clear;
   if reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',false) then
   begin
     Reg.GetValueNames(val);[/font]
[font=Verdana]     for i:=0 to val.Count-1 do
     begin
        listview1.Items.Add.Caption:=reg.ReadString(val.Strings[i])
     end;
   end;[/font]
[font=Verdana]end;[/font]
[font=Verdana][url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1.N4Click(Sender: TObject);
var
Val:TStringList;
i:integer;
begin
  reg:=Tregistry.Create;
   Val:=TStringList.Create;
   reg.RootKey:=HKEY_CURRENT_USER;
   if reg.OpenKey('Software\Microsoft\Internet Explorer\TypedURLs',false) then
   begin
     Reg.GetValueNames(val);
      for i:=0 to val.Count-1 do
    begin
    //listview1.Items[i].Selected;
    reg.DeleteValue(val.Strings[i]);
    listview1.Clear;
   end;
   end;
    end;[/font]
[font=Verdana]
[url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1.N2Click(Sender: TObject);
begin
  { if  (listview1.SelCount<>0) and  (listview1.SelCount<2) then
    ShellExecute(0, 'open', 'iexplore.exe', pchar(listview1.Selected.Caption), '',SW_SHOWNORMAL) else
     StatusBar1.Panels[0].Text:='请选中一个要访问的目标URL地址!';
end; }
end;
[url=http://www.xuedelphi.cn/][color=#810081]procedure[/color][/url] T[url=http://www.xuedelphi.cn/][color=#810081]Form[/color][/url]1.delphi1Click(Sender: TObject);
begin
shellexecute(handle,'open','[url=http://www.xuedelphi.cn][color=#0000ff]http://www.xuedelphi.cn'[/color][/url],nil,nil,sw_show);
end;
end.
运行效果:[img]http://www.xuedelphi.cn/wenzhang/UploadPic/2007-12/2007122311592926620.jpg[/img]
本文来自学delphi网,转载请注明出处:
[url=http://www.xuedelphi.cn/wenzhang/yytg/2007/12/200712231971.htm]http://www.xuedelphi.cn/wenzhang/yytg/2007/12/200712231971.htm[/url]
[/font][/font]

89_G 2008-4-20 12:57

__a15
页: [1]
查看完整版本: delphi写的IE地址栏选择性清理助手代码