PSPropertyKeyFromString function (propsys.h)

Converts a string to a PROPERTYKEY structure.

Syntax

PSSTDAPI PSPropertyKeyFromString(
  [in]  LPCWSTR     pszString,
  [out] PROPERTYKEY *pkey
);

Parameters

[in] pszString

Type: LPCWSTR

Pointer to a null-terminated, Unicode string to be converted.

[out] pkey

Type: PROPERTYKEY*

When this function returns, contains a pointer to a PROPERTYKEY structure.

Return value

Type: HRESULT

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

Remarks

The string to be converted must be formatted as "{fmtid} pid". For instance, the string that corresponds to PKEY_Title is: "{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2". PSStringFromPropertyKey outputs strings in this format.

This function succeeds for any valid property key string, even if the property does not exist in the property schema.

Examples

The following example, to be included as part of a larger program, demonstrates how to use PSPropertyKeyFromString.

PROPERTYKEY key;

HRESULT hr = PSPropertyKeyFromString(L"{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2", &key);

if (SUCCEEDED(hr))
{
    // The key variable is now valid.
}

Requirements

   
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 propsys.h
Library Propsys.lib
DLL Propsys.dll (version 6.0 or later)
Redistributable Windows Desktop Search (WDS) 3.0

See also

PSGetPropertyKeyFromName

PSStringFromPropertyKey