GetHGlobalFromILockBytes function (coml2api.h)

The GetHGlobalFromILockBytes function retrieves a global memory handle to a byte array object created using the CreateILockBytesOnHGlobal function.

Syntax

HRESULT GetHGlobalFromILockBytes(
  [in]  LPLOCKBYTES plkbyt,
  [out] HGLOBAL     *phglobal
);

Parameters

[in] plkbyt

Pointer to the ILockBytes interface on the byte-array object previously created by a call to the CreateILockBytesOnHGlobal function.

[out] phglobal

Pointer to the current memory handle used by the specified byte-array object.

Return value

This function returns HRESULT.

Remarks

After a call to CreateILockBytesOnHGlobal, which creates a byte array object on global memory, GetHGlobalFromILockBytes retrieves a pointer to the handle of the global memory underlying the byte array object. The handle this function returns might be different from the original handle due to intervening calls to the GlobalReAlloc function.

The contents of the returned memory handle can be written to a clean disk file, and then opened as a storage object using the StgOpenStorage function.

This function only works within the same process from which the byte array was created.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header coml2api.h (include Ole2.h)
Library Ole32.lib
DLL Ole32.dll

See also

CreateILockBytesOnHGlobal

StgOpenStorage