使用OLE控制IE
unit ligwin1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls, StdCtrls,ComObj, Shellapi;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
app:Variant;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
try
app.Navigate('c:/chih_com/index.html');
app.Visible:=TRUE;
except
//on EOleSysError do MessageBox(0,'EOleSysError','提示信息',MB_OK);
app:=CreateOleObject('InternetExplorer.Application');
app.Navigate('c:/chih_com/index.html');
app.Visible:=TRUE;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
app:=CreateOleObject('InternetExplorer.Application');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
try
app.Navigate('c:/chih_com/index.html',1);
app.Visible:=TRUE;
except
app:=CreateOleObject('InternetExplorer.Application');
app.Navigate('c:/chih_com/index.html');
app.Visible:=TRUE;
end;
end;
end.