GetHostNames method

List<IHostName> GetHostNames()

Implementation

List<IHostName> GetHostNames() {
  final retValuePtr = calloc<COMObject>();

  final hr = ptr.ref.vtable
      .elementAt(9)
      .cast<
          Pointer<
              NativeFunction<
                  HRESULT Function(
        Pointer,
        Pointer<COMObject>,
      )>>>()
      .value
      .asFunction<
          int Function(
        Pointer,
        Pointer<COMObject>,
      )>()(
    ptr.ref.lpVtbl,
    retValuePtr,
  );

  if (FAILED(hr)) throw WindowsException(hr);

  try {
    return IVectorView<IHostName>(
      retValuePtr,
      creator: IHostName.new,
      allocator: allocator,
    ).toList();
  } finally {
    free(retValuePtr);
  }
}