本文整理自网络,侵删。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellAPI, SHDocVw, mshtml;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(Handle, 'open', 'http://www.j7j8.com/', nil, nil, SW_ShowNormal);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i: integer;
vi: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
spDisp.QueryInterface( iWebBrowser2, IE1 );
if IE1 <> nil then
begin
memo1.Lines.Add( 'Location: '+ie1.LocationName );
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
begin
memo1.Lines.add( 'Title: ' + IDOC1.Title );
memo1.Lines.add( 'Url: ' + IDOC1.url);
end;
end;
end;
end;
end.
相关阅读 >>
Delphi 检查程序是否在(vm,vpc等)虚拟机运行 Delphi(测试可用)
Delphi 的字符及字符串 - char、ansichar、widechar、pchar、pansichar、pwidechar
更多相关阅读请进入《Delphi》频道 >>