1、如果只是获取当前的网页地址就不用说了】
如何获取所有打开的网页的地址?以IE为例,一个浏览器,但有N个标签,每个标签都是一个打开的网页,那么怎么把所有的网页地址同时得到呢?
是同时所有!
是同时所有!
是同时所有!
是同时所有!
是同时所有!
是同时所有!
如果觉得分少,可以另开贴再加,只要能回答满意。邮箱:[email protected]
如何获取所有打开的网页的地址?以IE为例,一个浏览器,但有N个标签,每个标签都是一个打开的网页,那么怎么把所有的网页地址同时得到呢?
是同时所有!
是同时所有!
是同时所有!
是同时所有!
是同时所有!
是同时所有!
如果觉得分少,可以另开贴再加,只要能回答满意。邮箱:[email protected]
解决方案 »
- Missing Data Provider or Data Packet,欢迎up
- 请问如何使用LISTVIEW的FINDCAPTION
- ado 跨数据库数据转化
- SimpleObjectBroker到底用来干什么啊?
- 救命啊:Delphi中如何实现对Windows的IE和关闭系统对话框的控制?
- 怎么把实型数转换成字符串型?
- NMHTTP的POST方法只能传送字符串,有可传送任意数据类型的控件?
- Delphi的远程数据库连接问题
- 给timer传递一个object,让timer实现每隔1秒移动object一次...
- 计算机专业本科生的悲哀
- 如何取得当前打印机所用的纸张Form名称?
- ???如何点击按钮实现 像网页在线客服那样与QQ即时对话???
http://it.china-b.com/cxsj/delphi/20090820/146211_1.html
dde参考地址。
shdocvw_tlb; procedure TForm1.Button1Click(Sender: TObject);
var
x: Integer;
Sw: IShellWindows;
begin
sw := CoShellWindows.Create;
for x := 0 to SW.Count - 1 do
Listbox1.Items.Add((Sw.Item(x) as IWebbrowser2).LocationUrl);
end;
Sinking events from IShellWindows. DShellWindowsEvent has two events OnWindowRegistered (called when a new instance of IE is created) and OnWindowRevoked (called whel an instance of IE is closed). Drop a DShellWindowEvent-component on your form and connect it to your instance of IShellwindows: var
sw : Ishellwindows; begin
sw := CoShellWindows.Create;
DshellwindowsEvents1.Connect(sw);
end;
The following code will keep track of running instances of Internet Explorer - add or remove them from a listbox based on information from OnWindowRegistered and OnWindowRevoked uses
shdocvw_tlb;
procedure TForm1.DShellWindowsEvents1WindowRegistered(Sender: TObject;lCookie: Integer);
begin
Listbox1.Items.Add( 'Instance with Cookie no: '+InttoStr(lCookie));
end; procedure TForm1.DShellWindowsEvents1WindowRevoked(Sender: TObject;lCookie: Integer);
begin
Listbox1.Items.Delete(Listbox1.Items.IndexOf( 'Instance with Cookie no: '+InttoStr(lCookie)));
end; procedure TForm1.FormCreate(Sender: TObject);
var
sw : Ishellwindows;
begin
FormStyle:=fsStayOnTop;
sw := CoShellWindows.Create;
DshellwindowsEvents1.Connect(sw);
end;
Sending commands to a running instance of IE You can obtain an IWebbrowser2-interface from each of the running instances listed in IShellwindows by simple typecasting if WB:=Shellwindows.Items(x) as IWebbrowser2;
The following code will close all running instances of IE when Button1 is clicked:
procedure TForm1.Button1Click(Sender: TObject);
var
x : Integer;
sw: Ishellwindows;
wb: IWebbrowser2;
begin
sw := CoShellWindows.Create;
for x := 0 to sw.count do
begin
WB := Sw.Item(x) as IWebbrowser2;
if wb <> nil then WB.Quit;
end;
end;
Sinking Events from a running instance of IE. Drop a DWebbrowserEvents2-component on your form and connect it to an instance of IE by using DWebbrowserEvents21.Connect(IE);
var
ShellWin : shdocvw_tlb.IShellWindows;
IE : IWebbrowser2; begin
IE:=shellwin.Item(Shellwin.Count-1) as IWebbrowser2;
DWebbrowserEvents21.Connect(IE);
end;
The following code opens a new instance of IE, lets it navigate and captures the statustext-change in a listbox: uses
shdocvw_tlb; procedure TForm1.Button1Click(Sender: TObject);
var
x: Olevariant;
sw: Ishellwindows;
wb: IWebbrowser2;
begin
WB := CoInternetExplorer.Create;
WB.Visible := True;
DWebbrowserEvents21.Connect(WB);
WB.Navigate( 'http://www.euromind.com/iedelphi ', x, x, x, x);
end; procedure TForm1.DWebBrowserEvents21StatusTextChange(Sender: TObject;const Text: WideString);
begin
listbox1.items.add(text);
end; procedure TForm1.DWebBrowserEvents21Quit(Sender: TObject);
begin
DWebbrowserEvents21.DisConnect;
end;
The demo LogView demonstrates how to log events from all running instances of IE to a common log-listbox. The demo uses DWebbrowserEvents2 and ShellWindowEvents:
var
ShellWin: IShellWindows; //NB!!
Connection: Integer; procedure InterfaceConnect(const Source: IUnknown; const IID: TIID;
const Sink: IUnknown; var Connection: Longint);
var
CPC: IConnectionPointContainer;
CP: IConnectionPoint;
begin
Connection := 0;
if Succeeded(Source.QueryInterface(IConnectionPointContainer, CPC)) then
if Succeeded(CPC.FindConnectionPoint(IID, CP)) then
CP.Advise(Sink, Connection);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
X: Integer;
begin
ShellWin := CoShellWindows.Create;
ShellWinEvents.Connect(ShellWin);
for x := 0 to ShellWin.Count - 1 do
InterfaceConnect(ShellWin.Item(x) as IWebbrowser2, DwebbrowserEvents2, WBevents, Connection);
end; procedure TForm1.ShellWinEventsWindowRegistered(Sender: TObject; lCookie: Integer);
begin
InterfaceConnect(ShellWin.Item(ShellWin.Count - 1) as IWebbrowser2, DwebbrowserEvents2, WBevents, Connection);
end; procedure TForm1.WBEventsBeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
listbox1.items.add(url);
end; 以上方法亲测通过,前提只适合IE内核浏览器,如果你用了搜狗、360的高速内核,是不行的