Skip to content

Latest commit

 

History

History
143 lines (91 loc) · 4.53 KB

nf-propvarutil-propvarianttouint32.md

File metadata and controls

143 lines (91 loc) · 4.53 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:propvarutil.PropVariantToUInt32
PropVariantToUInt32 function (propvarutil.h)
Extracts an ULONG value from a PROPVARIANT structure. If no value can be extracted, then a default value is assigned.
PropVariantToUInt32
PropVariantToUInt32 function [Windows Properties]
properties.PropVariantToUInt32
propvarutil/PropVariantToUInt32
shell.PropVariantToUInt32
shell_PropVariantToUInt32
properties\PropVariantToUInt32.htm
properties
ce1d8d07-2532-48bd-be8b-7650230dbe0d
12/05/2018
PropVariantToUInt32, PropVariantToUInt32 function [Windows Properties], properties.PropVariantToUInt32, propvarutil/PropVariantToUInt32, shell.PropVariantToUInt32, shell_PropVariantToUInt32
propvarutil.h
Windows
Windows XP with SP2, Windows Vista [desktop apps only]
Windows Server 2003 with SP1 [desktop apps only]
Propsys.lib
Propsys.dll (version 6.0 or later)
Windows
Windows Desktop Search (WDS) 3.0
19H1
PropVariantToUInt32
propvarutil/PropVariantToUInt32
c++
APIRef
kbSyntax
DllExport
Propsys.dll
PropVariantToUInt32

PropVariantToUInt32 function

-description

Extracts an ULONG value from a PROPVARIANT structure. If no value can be extracted, then a default value is assigned.

-parameters

-param propvarIn [in]

Type: REFPROPVARIANT

A reference to a source PROPVARIANT structure.

-param pulRet [out]

Type: ULONG*

When this function returns, contains the extracted property value if one exists; otherwise, 0.

-returns

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 ULONG value. For instance, an application obtaining values from a property store can use this to safely extract the ULONG value for UInt32 properties.

If the source PROPVARIANT has type VT_UI4, this helper function extracts the ULONG value. Otherwise, it attempts to convert the value in the PROPVARIANT structure into a ULONG. If a conversion is not possible, PropVariantToUInt32 will return a failure code and set pulRet to 0. See PropVariantChangeType for a list of possible conversions. Of note, VT_EMPTY is successfully converted to 0.

Examples

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

// IPropertyStore *ppropstore;

// Assume variable ppropstore is initialized and valid

PROPVARIANT propvar = {0};

HRESULT hr = ppropstore->GetValue(PKEY_Rating, &propvar);

if (SUCCEEDED(hr))

{

     // PKEY_Rating is expected to produce a VT_UI4 or VT_EMPTY value.

     // PropVariantToUInt32 will convert VT_EMPTY to 0.

     ULONG uRating;

     hr = PropVariantToUInt32(propvar, &uRating);

     if (SUCCEEDED(hr))

     {

             // uRating is now valid

     }

     else

     {

             // uRating is always 0

     }

     PropVariantClear(&propvar);

}

-see-also

InitPropVariantFromUInt32

PropVariantChangeType

PropVariantToUInt32Vector

VariantToUInt32