getDateTime method

DateTime getDateTime()

Implementation

DateTime getDateTime() {
  final retValuePtr = calloc<Uint64>();

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

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

    return DateTime.utc(1601, 01, 01)
        .add(Duration(microseconds: retValuePtr.value ~/ 10));
  } finally {
    free(retValuePtr);
  }
}