zoukankan      html  css  js  c++  java
  • delphi 保存网页MHT

    delphi 保存网页MHT

     
    uses ADODB_TLB, CDO_TLB, ComObj,MSHTML;
    {$R *.dfm}
    {能把网页如 WWW.QQ.COM保存为一个单文件 .MHT
    但不能把一个 A.HTM 保存为一个单文件 .MHT

    procedure WB_SaveAs_MHT(WB: TWebBrowser; FileName: TFileName);
    var
      Msg: IMessage;
      Conf: IConfiguration;
      Stream: _Stream;
      URL: Widestring;
    begin
     
      if not Assigned(WB.Document) then
        Exit;
      URL := WB.LocationURL;
     
      Msg := CoMessage.Create;
      Conf := CoConfiguration.Create;
      try
        Msg.Configuration := Conf;
        Msg.CreateMHTMLBody(URL, cdoSuppressNone, '', '');
        Stream := Msg.GetStream;
        Stream.SaveToFile(FileName, adSaveCreateOverWrite);
      finally
        Msg := nil;
        Conf := nil;
        Stream := nil;
      end;
    end; (* WB_SaveAs_MHT *)
    procedure TForm1.FormCreate(Sender: TObject);
    var
      f: string;
    begin
      f := ExtractFilePath(Application.ExeName) + 'WebDoc.htm';
      WebBrowser1.Navigate('file:///C:UsersAdminDesktop新建文件夹WebDoc.htm');
    end;
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      WB_SaveAs_MHT(WebBrowser1,'C:UsersAdminDesktop11.mht');
    end;
     
     
    ADODB_TLB.pas
     
    CDO_TLB.pas
     
     
     
  • 相关阅读:
    Git查看、删除远程分支和tag(转自:http://zengrong.net/post/1746.htm)
    设计模式工厂模式
    Android SystemProperties和Settings.System介绍(转自http://www.linuxidc.com/Linux/201108/40887.htm)
    设计模式原型模式
    设计模式建造者模式(转自:http://www.cnblogs.com/cbf4life/archive/2010/01/14/1647710.html)
    读取其他程序的sharedpreference
    eclipse下导入android源码
    国外程序员推荐:每个程序员都应读的书(转自:http://blog.jobbole.com/5886/)
    Android系统如何实现UI的自适应(在res下找对应目录)【转】
    Android Provision (Setup Wizard) (转自:http://blog.csdn.net/thl789/article/details/7803439)
  • 原文地址:https://www.cnblogs.com/xe2011/p/3876347.html
Copyright © 2011-2022 走看看