6#include <QtCore/qstring.h>
7#include <QtCore/qdebug.h>
8#include <QtCore/private/qsystemerror_p.h>
9#include <QtMultimedia/private/qcomtaskresource_p.h>
10#include <QtMultimedia/private/qwindows_scopedpropvariant_p.h>
12#include <mmdeviceapi.h>
14#include <propvarutil.h>
24q23::expected<PropertyStoreHelper, QString>
27 ComPtr<IPropertyStore> props;
28 HRESULT hr = device->OpenPropertyStore(STGM_READ, props.GetAddressOf());
30 return q23::unexpected{ QSystemError::windowsComString(hr) };
32 return PropertyStoreHelper(std::move(props));
37 ScopedPropVariant variant;
39 if (!SUCCEEDED(m_props->GetValue(property, variant.get())))
42 QComTaskResource<WCHAR> str;
43 HRESULT hr = PropVariantToStringAlloc(*variant, str.address());
45 return QString::fromWCharArray(variant->pwszVal);
47 qWarning() <<
"PropertyStoreHelper::getString: PropVariantToStringAlloc failed"
48 << QSystemError::windowsComString(hr);
54 ScopedPropVariant variant;
56 if (!SUCCEEDED(m_props->GetValue(property, variant.get())))
60 HRESULT hr = PropVariantToUInt32(*variant, &ret);
62 return uint32_t{ ret };
64 qWarning() <<
"PropertyStoreHelper::getUInt32: PropVariantToUInt32 failed"
65 << QSystemError::windowsComString(hr);
75struct first_arg_is_ptr;
78template <
typename Result,
typename Arg,
typename... Args>
79struct first_arg_is_ptr<Result (*)(Arg, Args...)> : std::bool_constant<std::is_pointer_v<Arg>>
83auto wrapPropVariantArg(
const PROPVARIANT &arg)
85 if constexpr (first_arg_is_ptr<
decltype(&PropVariantToGUID)>::value) {
96 ScopedPropVariant variant;
98 if (!SUCCEEDED(m_props->GetValue(property, variant.get())))
102 HRESULT hr = PropVariantToGUID(wrapPropVariantArg(*variant), &ret);
106 qWarning() <<
"PropertyStoreHelper::getUInt32: PropVariantToUInt32 failed"
107 << QSystemError::windowsComString(hr);
Combined button and popup list for selecting options.
struct _tagpropertykey PROPERTYKEY