PropVariantToDoubleVectorAlloc function (propvarutil.h)

Extracts data from a PROPVARIANT structure into a newly-allocated double vector.

Syntax

PSSTDAPI PropVariantToDoubleVectorAlloc(
  [in]  REFPROPVARIANT propvar,
  [out] DOUBLE         **pprgn,
  [out] ULONG          *pcElem
);

Parameters

[in] propvar

Type: REFPROPVARIANT

Reference to a source PROPVARIANT structure.

[out] pprgn

Type: DOUBLE**

When this function returns, contains a pointer to a vector of double values extracted from the source PROPVARIANT structure.

[out] pcElem

Type: ULONG*

When this function returns, contains the count of double elements extracted from the source PROPVARIANT structure.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

This helper function is used in places where the calling application expects a PROPVARIANT to hold a double vector value.

If the source PROPVARIANT has type VT_VECTOR | VT_R8 or VT_ARRAY | VT_R8, this function extracts a vector of double values into a newly allocated vector of DOUBLE values. The calling application is responsible for using CoTaskMemFree to release the vector pointed to by pprgn when it is no longer needed.

Examples

The following example, to be included as part of a larger program, demonstrates how to use PropVariantToDoubleVector to access a double vector value in a PROPVARIANT.

// IPropertyStore *ppropstore;
// Assume variable ppropstore is initialized and valid
PROPVARIANT propvar = {0};
HRESULT hr = ppropstore->GetValue(PKEY_GPS_DestLongitude, &propvar);
if (SUCCEEDED(hr))
{
     // PKEY_GPS_DestLongitude is expected to produce a VT_VECTOR | VT_R8 with three values, or VT_EMPTY
     // PropVariantToDoubleVectorAlloc will return an error for VT_EMPTY
     DOUBLE *rgLongitude;
     ULONG cElem;
     hr = PropVariantToDoubleVectorAlloc(propvar, &rgLongitude, &cElem);
     if (SUCCEEDED(hr))
     {
         if (cElem == 3)
         {
              // rgLongitude contains 3 doubles representing the degrees, minutes, and seconds of longitude
         }
         CoTaskMemFree(rgLongitude);
     }
     else
     {
          // propvar either is VT_EMPTY, or contains something other than a vector of  doubles
     }
     PropVariantClear(&propvar);
}

Requirements

Requirement Value
Minimum supported client Windows XP with SP2, Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 with SP1 [desktop apps only]
Target Platform Windows
Header propvarutil.h
Library Propsys.lib
DLL Propsys.dll (version 6.0 or later)
Redistributable Windows Desktop Search (WDS) 3.0

See also

InitPropVariantFromDoubleVector

PropVariantGetDoubleElem

PropVariantToDouble

PropVariantToDoubleVector

VariantToDoubleArray