1
11830
Unregistered / Unconfirmed
GUEST, unregistred user!
以下是我的代码,执行时报错(Unknown Error.),请高人调试一下,将程序发到我的邮件中getrose@sina.com,谢谢
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw,ComObj,CDO_TLB, ADODB_TLB;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
SaveDialog1: TSaveDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure WB_SaveAs_MHT(WB: TWebBrowser; FileName: TFileName);
var
Msg: IMessage;
Conf: IConfiguration;
Stream: _Stream;
URL : widestring;
begin
if not Assigned(WB.Document) then Exit;
URL := WB.LocationURL;
Msg := CoMessage.Create;
Conf := CoConfiguration.Create;
try
Msg.Configuration := Conf;
Msg.CreateMHTMLBody(URL, cdoSuppressAll, '', '');
Stream := Msg.GetStream;
Stream.SaveToFile(FileName, adSaveCreateOverWrite);
finally
Msg := nil;
Conf := nil;
Stream := nil;
end;
end; (* WB_SaveAs_MHT *)
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate(Edit1.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
WB_SaveAs_MHT(WebBrowser1,SaveDialog1.FileName);
end;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw,ComObj,CDO_TLB, ADODB_TLB;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
SaveDialog1: TSaveDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure WB_SaveAs_MHT(WB: TWebBrowser; FileName: TFileName);
var
Msg: IMessage;
Conf: IConfiguration;
Stream: _Stream;
URL : widestring;
begin
if not Assigned(WB.Document) then Exit;
URL := WB.LocationURL;
Msg := CoMessage.Create;
Conf := CoConfiguration.Create;
try
Msg.Configuration := Conf;
Msg.CreateMHTMLBody(URL, cdoSuppressAll, '', '');
Stream := Msg.GetStream;
Stream.SaveToFile(FileName, adSaveCreateOverWrite);
finally
Msg := nil;
Conf := nil;
Stream := nil;
end;
end; (* WB_SaveAs_MHT *)
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate(Edit1.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
WB_SaveAs_MHT(WebBrowser1,SaveDialog1.FileName);
end;
end;
end.