本文整理自网络,侵删。
uses ActiveX,ComObj;
const CLSID_ShellUIHelper: TGUID = '{64AB4BB7-111E-11D1-8F79-00C04FC2FBE1}';
procedure AddFavorite(Webbrowser:TWebBrowser);varShellUIHelper: ISHellUIHelper;url, title: Olevariant;begin Title := Webbrowser.LocationName; Url := Webbrowser.LocationUrl; if Url <>'' then begin ShellUIHelper := CreateComObject(CLSID_SHELLUIHELPER) as IShellUIHelper; ShellUIHelper.AddFavorite(url, title); end;end;
procedure TForm1.Button1Click(Sender: TObject);
beginAddFavorite(WebBrowser1);end;
procedure TForm1.FormCreate(Sender: TObject);beginWebBrowser1.Navigate('http://www.delphitop.com');end;
相关阅读 >>
Delphi if语法,弹出提示框,不等于写法,判断是否为空
Delphi tnethttpclient https忽略证书验证
更多相关阅读请进入《Delphi》频道 >>