GetHGlobalFromStream function ole32
Retrieves the global memory handle to a stream that was created through a call to the CreateStreamOnHGlobal function.
Throws a WindowsException on failure.
To learn more, see learn.microsoft.com/windows/win32/api/combaseapi/nf-combaseapi-gethglobalfromstream.
Implementation
HGLOBAL GetHGlobalFromStream(IStream? pstm) {
final phglobal = adaptiveCalloc<Pointer>();
final hr$ = HRESULT(_GetHGlobalFromStream(pstm?.ptr ?? nullptr, phglobal));
if (hr$.isError) {
free(phglobal);
throw WindowsException(hr$);
}
final result$ = phglobal.value;
free(phglobal);
return .new(result$);
}