以下过程适用于 Windows XP、7-32、7-64、8-32、8-64,IE 8 至 11 版本不适用于新的 Windows 10,请参阅代码:
try
IDoc := CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
IDoc.Write(PSafeArray(VarArrayAsPSafeArray(VarArrayOf([xHtml])))); //Error windows 10
IDoc.Close;
except
on E: Exception do
begin
//E.ClassName = EOleException
//E.Message = Unspecified error
end;
end;
xHtml
是一个包含 HTML 的字符串"<html>...</html>"
我也尝试以这种方式编写 IHTMLDocument2 ,但出现了同样的错误:
IDoc := CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
v := VarArrayCreate([0, 0], VarVariant);
v[0] := xHtml;
IDoc.Write(PSafeArray(TVarData(v).VArray));
IDoc.Close;
我还检查了 Windows 10 中是否有一个mshtml.dll
,并且有。