语言

AutomationElement.ProcessIdProperty 字段

定义

标识 ProcessId 属性。

public: static initonly System::Windows::Automation::AutomationProperty ^ ProcessIdProperty;
public static readonly System.Windows.Automation.AutomationProperty ProcessIdProperty;
 staticval mutable ProcessIdProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly ProcessIdProperty As AutomationProperty 

字段值

示例

以下示例检索属性的当前值。 如果元素不提供默认值,则返回默认值。

int processIdentifier = (int)
    autoElement.GetCurrentPropertyValue(AutomationElement.ProcessIdProperty);
Dim processIdentifier As Integer = _
    CInt(autoElement.GetCurrentPropertyValue(AutomationElement.ProcessIdProperty))

下面的示例检索属性的当前值,但指定如果元素本身不提供属性的值, NotSupported 则返回而不是默认值。

int processIdentifier1;
object processIdentifierNoDefault =
    autoElement.GetCurrentPropertyValue(AutomationElement.ProcessIdProperty, true);
if (processIdentifierNoDefault == AutomationElement.NotSupported)
{
    // TODO Handle the case where you do not wish to proceed using the default value.
}
else
{
    processIdentifier1 = (int)processIdentifierNoDefault;
}
Dim processIdentifier1 As Integer
Dim processIdentifierNoDefault As Object = autoElement.GetCurrentPropertyValue(AutomationElement.ProcessIdProperty, True)
If processIdentifierNoDefault Is AutomationElement.NotSupported Then
    ' TODO Handle the case where you do not wish to proceed using the default value.
Else
    processIdentifier1 = CInt(processIdentifierNoDefault)
End If

注解

此标识符由UI 自动化客户端应用程序使用。 UI 自动化提供程序应使用 AutomationElementIdentifiers 中的等效标识符。

也可以从 Current 或 Cached 属性中检索此属性。

属性的返回值为类型 Int32。 属性的默认值为 0。

适用于

另请参阅