item method

IMMDevice? item(
  1. int nDevice
)

Retrieves a pointer to the specified item in the device collection.

Throws a WindowsException on failure.

To learn more, see learn.microsoft.com/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdevicecollection-item.

Implementation

IMMDevice? item(int nDevice) {
  final ppDevice = adaptiveCalloc<VTablePointer>();
  final hr$ = HRESULT(_ItemFn(ptr, nDevice, ppDevice));
  if (hr$.isError) {
    free(ppDevice);
    throw WindowsException(hr$);
  }
  final result$ = ppDevice.value;
  free(ppDevice);
  if (result$.isNull) return null;
  return .new(result$);
}