您现在的位置:首页 >> 基础算法 >> window基础 >> 内容

一个将HTML代码转换成IHTMLDocument2接口的函数

时间:2011/9/3 15:38:18 点击:

  核心提示:function HTML2Intf(str:string):IHTMLDocument2;var hgbl: HGLOBAL; Stream: IStream; doc: ihtmldocument...
function HTML2Intf(str:string):IHTMLDocument2;
var
  hgbl: HGLOBAL;
  Stream: IStream;
  doc: ihtmldocument2;
  psi: IPersistStreamInit;
begin
  try
    hgbl:=GlobalAlloc(GPTR,Length(str)+1);
    if   0=hgbl   then   RaiseLastWin32Error;
    CopyMemory(Pointer(hgbl),PChar(str),Length(str));
    CreateStreamOnHGlobal(hgbl,True,Stream);
    doc.QueryInterface(IPersistStreamInit,psi);
    psi.InitNew;
    psi.Load(Stream);
    result:=doc;
  except
     result := nil;
  end;
end;

作者:网络 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号