IMFMetadata::GetProperty method
Gets the value of a metadata property.
Syntax
HRESULT GetProperty(
[in] LPCWSTR pwszName,
[out] PROPVARIANT *ppvValue
);
Parameters
- pwszName [in]
-
A pointer to a null-terminated string that containings the name of the property. To get the list of property names, call IMFMetadata::GetAllPropertyNames.
- ppvValue [out]
-
Pointer to a PROPVARIANT that receives the value of the property. The PROPVARIANT type depends on the property. For multivalued properties, the PROPVARIANT is a VT_VECTOR type. The caller must free the PROPVARIANT by calling PropVariantClear.
Return value
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
| Return code | Description |
|---|---|
|
The method succeeded. |
|
The requested property was not found. |
Examples
The following example takes an IMFMetadata and displays all of the metadata properties.
void DisplayProperty(REFPROPVARIANT var); HRESULT DisplayMetadata(IMFMetadata *pMetadata) { PROPVARIANT varNames; HRESULT hr = pMetadata->GetAllPropertyNames(&varNames); if (FAILED(hr)) { return hr; } for (ULONG i = 0; i < varNames.calpwstr.cElems; i++) { wprintf(L"%s\n", varNames.calpwstr.pElems[i]); PROPVARIANT varValue; hr = pMetadata->GetProperty( varNames.calpwstr.pElems[i], &varValue ); if (SUCCEEDED(hr)) { DisplayProperty(varValue); PropVariantClear(&varValue); } } PropVariantClear(&varNames); return hr; } void DisplayProperty(REFPROPVARIANT var) { // This function handles the most common PROPVARIANT types for metadata. switch (var.vt) { case VT_BLOB: wprintf(L"VT_BLOB\n"); break; case VT_BOOL: wprintf(L"VT_BOOL: %s\n", (var.boolVal == VARIANT_TRUE ? L"TRUE" : L"FALSE")); break; case VT_CLSID: { WCHAR guid[40]; StringFromGUID2(*var.puuid, guid, 40); wprintf(L"VT_CLSID: %s\n", guid); } break; case VT_EMPTY: wprintf(L"VT_EMPTY\n"); break; case VT_FILETIME: { SYSTEMTIME systemTime; FileTimeToSystemTime(&var.filetime, &systemTime); int cch = GetDateFormatEx( LOCALE_NAME_USER_DEFAULT, 0, &systemTime, NULL, NULL, 0, NULL); PWSTR pwstr = (PWSTR)CoTaskMemAlloc(cch * sizeof(WCHAR)); if (pwstr) { GetDateFormatEx( LOCALE_NAME_USER_DEFAULT, 0, &systemTime, NULL, pwstr, cch, NULL); wprintf(L"VT_FILETIME: %s\n", pwstr); CoTaskMemFree(pwstr); } } break; case VT_LPWSTR: wprintf(L"VT_LPWSTR: %s\n", var.pwszVal); break; case VT_UI4: wprintf(L"VT_UI4: %d\n", var.ulVal); break; case VT_UI8: wprintf(L"VT_UI8: %I64d\n", var.uhVal.QuadPart); break; case VT_VECTOR | VT_LPWSTR: for (ULONG i = 0; i < var.calpwstr.cElems; i++) { wprintf(L"VT_VECTOR | VT_LPWSTR: %s;", var.calpwstr.pElems[i]); } wprintf(L"\n"); break; default: wprintf(L"Variant type = %x\n", var.vt); break; } }
Requirements
|
Minimum supported client |
Windows Vista [desktop apps | Windows Store apps] |
|---|---|
|
Minimum supported server |
Windows Server 2008 [desktop apps | Windows Store apps] |
|
Header |
|
|
Library |
|
See also