解决方法
您可以使用
IPersistStreamInit
接口和
save方法将Webbrowser的内容存储在流中.
Uses ActiveX; function GetWebBrowserHTML(const WebBrowser: TWebBrowser): String; var LStream: TStringStream; Stream : IStream; LPersistStreamInit : IPersistStreamInit; begin if not Assigned(WebBrowser.Document) then exit; LStream := TStringStream.Create(''); try LPersistStreamInit := WebBrowser.Document as IPersistStreamInit; Stream := TStreamAdapter.Create(LStream,soReference); LPersistStreamInit.Save(Stream,true); result := LStream.DataString; finally LStream.Free(); end; end;