//-------------------------------------------------------
// 保存网页内容
// 修改人:司马华鹏
procedure TfrmMain.SaveHTMLSourceToFile(const FileName: string;WB: TWebBrowser);
var
PersistStream: IPersistStreamInit;
FileStream: TFileStream;
Stream: IStream;
SaveResult: HRESULT;
begin
PersistStream := WB.Document as IPersistStreamInit;
FileStream := TFileStream.Create(FileName, fmCreate);
try
Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
SaveResult := PersistStream.Save(Stream, True);
if FAILED(SaveResult) then
MessageBox(Handle, 'Fail to save HTML source', 'Error', mb_iconerror);
finally
FileStream.Free;
end;
end;