HtmlDocument.DomDocument 属性

定义

获取此 HtmlDocument 的非托管接口指针。

public:
 property System::Object ^ DomDocument { System::Object ^ get(); };
public object DomDocument { get; }
member this.DomDocument : obj
Public ReadOnly Property DomDocument As Object

属性值

Object

表示 Object 非托管文档的 IDispatch 指针。

示例

下面的代码示例将指针强制转换为DomDocumentIHTMLDocument2指针并显示属性的值lastModified,该值指示文档所有者上次更新其内容的时间。 The code example requires that you have a Button on your form named Button6.

private string GetLastModifiedDate()
{
    if (webBrowser1.Document != null)
    {
        MSHTML.IHTMLDocument2 currentDoc = (MSHTML.IHTMLDocument2)webBrowser1.Document.DomDocument;
        return (currentDoc.lastModified);
    }
    else
    {
        return ("");
    }
}
Private Function GetLastModifiedDate() As String
    If (Not (WebBrowser1.Document Is Nothing)) Then
        Dim CurrentDocument As MSHTML.IHTMLDocument2 = WebBrowser1.Document.DomDocument
        GetLastModifiedDate = CurrentDocument.lastModified
    Else
        GetLastModifiedDate = Nothing
    End If
End Function

注解

HtmlDocument 是 INTERNET Explorer 文档对象模型 (DOM) 的包装器,以 COM 编写。 如果需要访问基础 COM 接口上的未公开属性或方法,例如 IHTMLDocument2,可以使用此对象来查询它们。

若要使用非托管接口,请将 MSHTML 库 (mshtml.dll) 导入应用程序。 但是,也可以使用该方法 IDispatch::Invoke 执行未公开的属性和方法。

适用于

另请参阅