www.pudn.com > ChaoJiQiDong.rar > u_NetSite.pas, change:2009-11-21,size:2546b


unit u_NetSite; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, StdCtrls, Buttons,Comobj,OleCtrls,SHDocVw,mxOutlookBarPro, ComCtrls,u_ListView,u_Main, 
  ImgList; 
 
type 
  TForm5 = class(TForm) 
    BitBtn1: TBitBtn; 
    BitBtn2: TBitBtn; 
    ListView1: TListView; 
    procedure FormCreate(Sender: TObject); 
    procedure BitBtn1Click(Sender: TObject); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  Form5: TForm5=NIL; 
  MondifyHeader:TmxHeader=NIL; 
implementation 
 uses u_OutlookBar; 
{$R *.dfm} 
 
Function   GetUrlType(MyUrl:string):string; 
begin 
      Result:='未知'; 
      Trim(MyUrl); 
      if MyUrl='' then exit; 
      if (Pos('www.',MyUrl)<>0) or (Pos('http://',MyUrl)<>0) then 
      begin 
          Result:='网站服务器'; 
          exit; 
      end; 
 
      if Pos('file:///', MyUrl)<>0 then 
      begin 
           if Pos('%20',MyUrl)<>0 then 
              Result:='局域网内' 
           else 
              Result:='本地磁盘'; 
      end; 
end; 
 
Function   GetUrl:Boolean; 
var 
  i: Integer; 
  Browser: IWebBrowser2; 
  sw : TShellWindows ; 
  Url,UrlName:string; 
begin 
     try 
        sw := TShellWindows.Create(Application); 
        try 
            for i:=0 to sw.Count-1 do 
            begin 
               Browser := sw.Item(i) as IWebBrowser2; 
               Url:=Browser.LocationURL; 
               UrlName:= Browser.LocationName; 
               ListView_AddItems(Form5.ListView1,[InttoStr(i),UrlName,Url,GetUrlType(Url)]); 
            end; 
        except 
        end; 
     finally 
        sw.Free ; 
     end; 
end; 
 
procedure TForm5.FormCreate(Sender: TObject); 
begin 
  ListView1.Columns[0].Width:=0; 
  SetWindowPos(Form5.handle,HWND_TOPMOST,Left,Top,Width,Height,0); 
  GetUrl; 
end; 
 
procedure TForm5.BitBtn1Click(Sender: TObject); 
var 
  Index:Integer; 
  NewButton:TmxButton; 
  UrlName,Url:string; 
begin 
     Index :=ListView1.ItemIndex; 
     if Index=-1 then exit; 
     if MondifyHeader=NIL then exit; 
     UrlName:=ListView_ModifyListViewByCaption(ListView1,Index,'标题','返回'); 
     Url:=ListView_ModifyListViewByCaption(ListView1,Index,'地址','返回'); 
     NewButton:=AddNewButton(MondifyHeader,UrlName); 
     NewButton.Hint:=Url; 
     NewButton.OnClick:=Form1.mxOutlookBarProHeadersButtonsClick; 
     AddButtontoHeadFile(MyPath+HeaderFileName,MondifyHeader.Caption,UrlName); 
     AddButtontoFile(MyPath+BtnFileName,UrlName,Url); 
end; 
 
end.