Windows Dev Center

Expand Minimize

PropVariantToDoubleVectorAlloc function

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

Syntax


HRESULT PropVariantToDoubleVectorAlloc(
  _In_  REFPROPVARIANT propvar,
  _Out_ DOUBLE         **pprgn,
  _Out_ ULONG          *pcElem
);

Parameters

propvar [in]

Type: REFPROPVARIANT

Reference to a source PROPVARIANT structure.

pprgn [out]

Type: DOUBLE**

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

pcElem [out]

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

Minimum supported client

Windows XP with SP2, Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 with SP1 [desktop apps only]

Redistributable

Windows Desktop Search (WDS) 3.0

Header

Propvarutil.h

Library

Propsys.lib

DLL

Propsys.dll (version 6.0 or later)

See also

InitPropVariantFromDoubleVector
PropVariantToDouble
PropVariantGetDoubleElem
PropVariantToDoubleVector
VariantToDoubleArray

 

 

Community Additions

ADD
Show:
© 2015 Microsoft