Help Center

DVARIANT.ToBuffermethod

Extracts the contents of a DVARIANT of type VT_ARRRAY OR VT_UI1 to a buffer.

COMmethodDVARIANT.INCdocumented

Syntax

FUNCTION ToBuffer (BYVAL pv AS VOID PTR, BYVAL cb AS UINT) AS HRESULT

Parameters

NameDescription
pvPointer to a buffer of length cb bytes. When this function returns, contains the first cb bytes of the extracted buffer value.
cbThe size of the pv buffer, in bytes. The buffer should be the same size as the data to be extracted, or smaller.

Return value

Returns one of the following values:

Description

Extracts the contents of a DVARIANT of type VT_ARRRAY OR VT_UI1 to a buffer.

Remarks

This function is used when the calling application expects a VARIANT to hold a buffer value. The calling application should check that the value has the expected length before it calls this function.

If DVARIANT has type VT_ARRAY OR VT_UI1, this function extracts the first cb bytes from the structure and places them in the buffer pointed to by pv.

If the stored value has fewer than cb bytes, then function fails and the buffer is not modified.

If the value has more than cb bytes, then function succeeds and truncates the value.

To retrieve the size of the array call GetElementCount.

Example

DIM dv AS DVARIANT DIM strIn AS STRING = "Test string" dv.PutBuffer(STRPTR(strIn), LEN(strIn))

DIM nBytes AS LONG = dv.GetElementCount DIM strOut AS STRING = SPACE(nBytes) dv.ToBuffer(STRPTR(strOut), nBytes) PRINT strOut

Reference

  • Include file DVARIANT.INC
  • Defined in AfxNova/DVARIANT.inc:1784
  • Documented in COM/DVARIANT Class.md
  • Topic: DVARIANT Class