getCachedPattern method

IUnknown? getCachedPattern(
  1. UIA_PATTERN_ID patternId
)

Retrieves from the cache the IUnknown interface of the specified control pattern of this UI Automation element.

Throws a WindowsException on failure.

To learn more, see learn.microsoft.com/windows/win32/api/uiautomationclient/nf-uiautomationclient-iuiautomationelement-getcachedpattern.

Implementation

IUnknown? getCachedPattern(UIA_PATTERN_ID patternId) {
  final patternObject = adaptiveCalloc<VTablePointer>();
  final hr$ = HRESULT(_GetCachedPatternFn(ptr, patternId, patternObject));
  if (hr$.isError) {
    free(patternObject);
    throw WindowsException(hr$);
  }
  final result$ = patternObject.value;
  free(patternObject);
  if (result$.isNull) return null;
  return .new(result$);
}