我已经调试通过,但是在选择浏览器窗口上有问题
下面是全部源代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, MSHtml, OleServer, ActiveX;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
IE: TInternetExplorer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
IE := TInternetExplorer.Create(Self);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
vDoc: OleVariant;
IpStream: IPersistStreamInit;
Stm: TMemoryStream;
st: TStrings;
begin
IE.ConnectKind := ckRunningInstance;
IE.Connect;
vDoc := IE.Document;
if Assigned(IDispatch(vDoc)) then
begin
Stm := TMemoryStream.Create;
st := TStringList.Create;
IpStream := IDispatch(vDoc) as IPersistStreamInit;
IpStream.save(TStreamAdapter.Create(Stm), TRUE);
Stm.Position := 0;
st.LoadFromStream(Stm);
Stm.Free;
Memo1.Lines := st;
st.Free;
end;
end;
end.