// Create a PropertyNameArray object and add property names to it CComPtrspPropList; HRESULT hr = PSGetPropertyDescriptionListFromString(L"prop:System.ItemNameDisplay", IID_PPV_ARGS(&spPropList)); if (SUCCEEDED(hr)) { CComPtr spPropNameArray; hr = spPropList->GetPropertyDescriptionByName(L"System.ItemNameDisplay", IID_PPV_ARGS(&spPropNameArray)); if (SUCCEEDED(hr)) { spPropNameArray->Add(L"System.ItemType"); spPropNameArray->Add(L"System.Size"); } }
// Get the number of property names in a PropertyNameArray object UINT uCount = 0; CComPtrIn this example, we retrieve the number of property names in a PropertyNameArray object and output it to the console. The PropertyNameArray class is part of the Windows Shell COM library.spPropNameArray; // ... initialize spPropNameArray ... if (spPropNameArray != nullptr) { HRESULT hr = spPropNameArray->GetCount(&uCount); if (SUCCEEDED(hr)) { wprintf(L"The PropertyNameArray contains %u property names\n", uCount); } }