Bluetooth (Windows): adds a string variant helper; removes propsys dependency

This commit is contained in:
李通洲
2026-03-03 10:45:11 +08:00
parent 75f4a3d92d
commit b86c0880b9
5 changed files with 40 additions and 26 deletions
@@ -6,8 +6,6 @@ extern "C"
#include "common/windows/unicode.hpp"
#include "common/windows/util.hpp"
STDAPI InitVariantFromStringArray(_In_reads_(cElems) PCWSTR *prgsz, _In_ ULONG cElems, _Out_ VARIANT *pvar);
extern "C"
const char* ffBluetoothDetectBattery(FFlist* devices)
{
@@ -27,13 +25,7 @@ const char* ffBluetoothDetectBattery(FFlist* devices)
if (FAILED(pnpEntityClass->GetMethod(bstr_t(L"GetDeviceProperties"), 0, &pInParams, NULL)))
return "Failed to get GetDeviceProperties method";
VARIANT devicePropertyKeys;
PCWSTR props[] = { L"{104EA319-6EE2-4701-BD47-8DDBF425BBE5} 2", L"DEVPKEY_Bluetooth_DeviceAddress" };
if (FAILED(InitVariantFromStringArray(props, ARRAY_SIZE(props), &devicePropertyKeys)))
return "Failed to init variant from string array";
on_scope_exit releaseDevicePropertyKeys([&] { VariantClear(&devicePropertyKeys); });
FFWmiVariant devicePropertyKeys({ L"{104EA319-6EE2-4701-BD47-8DDBF425BBE5} 2", L"DEVPKEY_Bluetooth_DeviceAddress" });
if (FAILED(pInParams->Put(L"devicePropertyKeys", 0, &devicePropertyKeys, CIM_FLAG_ARRAY | CIM_STRING)))
return "Failed to put devicePropertyKeys";
}