delphi 用IWebbrowser2如何获取IE地址栏的网址?请高手帮忙...
解决方案 »
- 有关打印连打问题,急,急
- 怎么让TListBox出现水平滚动条
- 如何模拟对一个游戏进行输入?
- StringGird是不是有限制啊???
- 如果TClientSocket没有连接到Tserversocket就继续连接,但过一段时间就会出错,怎么回事?
- 如何在一个EDIT中写了内容以后接着按回车键,能执行该FORM中的指定BUTTON的响应功能??
- 怎样能把button画成圆形外观?
- Dll中的窗体的FormStyle能为fsMDIChild吗?
- 请MIS高手指教一下,怎么入门???(大家都来讨论一下!谢了!)
- 为什么我的DELPHI按Crtl+左键时,位置不对?
- char数组存储了一些不可见字符,然后存入数据库,读出后不正常
- 请教:图像叠加
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,SHDocVw, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
shell:IShellWindows;
i,count:Integer;
disp:IDispatch;
v:OleVariant;
ie:IWebBrowser2;
begin
shell := CoShellWindows.Create;
count := shell.Count;
for i:=0 to count - 1 do
begin
v := i;
disp := shell.Item(v);
if disp <> nil then
begin
disp.QueryInterface(IWebBrowser2,ie);
if ie <> nil then
begin
ShowMessage('程序:'+ie.LocationName+' 网址:'+ie.LocationURL);
end;
end;
end;
end;end.
很方便;
获取cookies: EmbeddedWB1.Cookie;
获取当前页面网址:EmbeddedWB1.LocationURL;
获取页面标题:EmbeddedWB1.LocationName;还有很多封装好的方法。记得用最新版的。老版本好像没有这些方法。 property LocationName: WideString index 210 read GetWideStringProp;
property LocationURL: WideString index 211 read GetWideStringProp;function TCustomEmbeddedWB._getCookie: WideString;
var
D: IHTMLDocument2;
begin
if Supports(Document, IHTMLDocument2, D) then
Result := OleObject.Document.Cookie
else
Result := '';
end;