一个问题,帮忙解答下!帮帮忙请进啊!谢谢..(15)

  • 主题发起人 主题发起人 netsen
  • 开始时间 开始时间
N

netsen

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下 编译出错,我检查了,不知道为什么?!unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, SHDocVw, StdCtrls;type TForm1 = class(TForm) Edit1: TEdit; Button1: TButton; Memo1: TMemo; WebBrowser1: TWebBrowser; procedure WebBrowser1DocumentComplete(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm} function GetHtml(const WebBrowser.TWebBrowser):string; const BufSize = $10000; var Size:Int64; Stream:IStream; hHTMLText:HGlobal; psi:IPersistStreamInt; begin if not Assigned(WebBrowser.Document) then Exit; OleCheck(WebBrowser.Documen.QueryInterface(IPersistStreamInit,psi)); try hHTMLText:=GlobalAlloc(GPTR,bUFsize); OleCheck(CreatStreamOnHGlobal(hHTMLText,True,Stream)); try OlECheck(psi.Save(Stream,False)); Size:=StrLen(PChar(hHTMLText)); SetLength(Size); CopyMemory(PChar(Result)),Pointer((hHTMLText),Size); finally Stream :=nil; end; finally psi:=nil; end; end;procedure TForm1.FormCreate(Sender: TObject);begin Memo1.Clear;end;procedure TForm1.Button1Click(Sender: TObject);begin WebBorwser1.Navigate(Edit1.Text);end;procedure TForm1.WebBrowser1DocumentComplete(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant);begin if WebBrowser1.Application =pDisp then Memo1.Text :=GetHtml(WebBrowser1);end;end.
 
把错误信息贴出来啊~~
 
朋友,你是用delphi写代码的吗?function GetHtml(const WebBrowser.TWebBrowser):string; --> function GetHtml(const WebBrowser:TWebBrowser):string;Stream: IStream; //需要引用某个单元,系统中ActiveX, types, Ole2都包含该定义OleCheck(WebBrowser.Documen.QueryInterface(IPersistStreamInit, psi)); --> OleCheck(WebBrowser.Document.QueryInterface(IPersistStreamInit, psi));OleCheck(CreatStreamOnHGlobal(hHTMLText, True, Stream)); //CreatStreamOnHGlobal 不知道什么单元的CopyMemory( PChar(Result)), Pointer((hHTMLText), Size); -->CopyMemory( PChar(Result), Pointer(hHTMLText), Size);WebBorwser1.Navigate(Edit1.Text); --> WebBrowser1.Navigate(Edit1.Text)代码不多,错误不少!劝你放弃。
 
接受答案了.
 
后退
顶部