保存webbrowser中的html内容
利用ipersist接口可以实现保存html到文件,在vb和delphi下的实现是这样的:
vb:
dim opf as ipersistfile
set opf = webbrowser1.document
opf.save "thefilenamehere.htm", false
delphi:至于vc下的实现方法,可以参考蒋晟的这篇文章:
uses
mshtml,olectrls, shdocvw, stdctrls,activex;
function gethtmlcode(wb: iwebbrowser2; acode: tstrings): boolean;
var
ps: ipersiststreaminit;
s: string;
ss: tstringstream;
sa: istream;
begin
ps := wb.document as ipersiststreaminit;
s := &&
ss := tstringstream.create(s);
try
sa:= tstreamadapter.create(ss, soreference) as istream;
result := succeeded(ps.save(sa, bool(true)));
if result then acode.add(ss.datastring);
finally
ss.free;
end;
end;
http://www.csdn.net/develop/read_article.asp?id=18465
另外vb地实现需要引用ole_lib,这个引用在 http://www.mvps.org/emorcillo/vb6/tlb/tl_ole.zip下载