Registriert seit: 10. Jun 2002
Ort: Unterhaching
11.412 Beiträge
Delphi 12 Athens
|
Re: Aktuelle Seite vom TWebbrowser sichern...
9. Mär 2004, 09:42
Die Funktion sollte helfen (ungetestet)
Delphi-Quellcode:
procedure TForm1.SaveHTMLSourceToFile( const FileName: string;
WB: TWebBrowser);
var
PersistStream: IPersistStreamInit;
FileStream: TFileStream;
Stream: IStream;
SaveResult: HRESULT;
begin
PersistStream := WB.Document as IPersistStreamInit;
if FileExists(FileName) then
DeleteFile(FileName);
FileStream := TFileStream.Create(FileName, fmCreate);
try
Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
SaveResult := PersistStream.Save(Stream, True);
if Failed(SaveResult) then
MessageBox( Handle, ' Failed to save HTML source', ' Error', 0);
finally
FileStream.Free;
end;
end;
pocedure TForm1.Button1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
SaveHTMLSourceToFile(SaveDialog1.FileName, WebBrowser1);
end;
... ...
Daniel Lizbeth Ich bin nicht zurück, ich tue nur so
|
|
Zitat
|