Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IRawElementProviderFragment::GetRuntimeId method

Retrieves the runtime identifier of an element.

Syntax


HRESULT GetRuntimeId(
  [out, retval] SAFEARRAY **pRetVal
);

Parameters

pRetVal [out, retval]

Type: SAFEARRAY**

Receives a pointer to the runtime identifier. This parameter is passed uninitialized.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Implementations should return NULL for a top-level element that is hosted in a window. Other elements should return an array that contains UiaAppendRuntimeId (defined in Uiautomationcoreapi.h), followed by a value that is unique within an instance of the fragment.

Examples

The following implementation for a list item returns a runtime identifier made up of the UiaAppendRuntimeId constant and the index of the item within the list.


HRESULT STDMETHODCALLTYPE ListItemProvider::GetRuntimeId(SAFEARRAY ** pRetVal)
{
    if (pRetVal == NULL) 
    {
        return E_INVALIDARG;
    }
    
    int rId[] = { UiaAppendRuntimeId, m_itemIndex };
    SAFEARRAY *psa = SafeArrayCreateVector(VT_I4, 0, 2);
    if (psa == NULL)
    {
        return E_OUTOFMEMORY;
    }
    
    for (LONG i = 0; i < 2; i++)
    {
        SafeArrayPutElement(psa, &i, (void*)&(rId[i]));
    }
    
    *pRetVal = psa;
    return S_OK;
}   

Requirements

Minimum supported client

Windows XP [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2003 [desktop apps | Windows Store apps]

Header

UIAutomationCore.h (include UIAutomation.h)

IDL

UIAutomationCore.idl

See also

Reference
IRawElementProviderFragment
Conceptual
Best Practices for Using Safe Arrays

 

 

Show:
© 2017 Microsoft