summaryrefslogtreecommitdiffstats
path: root/src/common/windows/variant.cpp
blob: d5610d3085b670c8836af14761717fbb181ddf30 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "variant.hpp"

#include <oleauto.h>

FFWmiVariant::FFWmiVariant(std::initializer_list<PCWSTR> strings) : FFWmiVariant() {
    SAFEARRAYBOUND bound = {
        .cElements = (ULONG) strings.size(),
        .lLbound = 0,
    };
    SAFEARRAY* psa = SafeArrayCreate(VT_BSTR, 1, &bound);

    LONG i = 0;
    for (PCWSTR str : strings) {
        SafeArrayPutElement(psa, &i, bstr_t(str));
        ++i;
    }

    this->vt = VT_ARRAY | VT_BSTR;
    this->parray = psa;
}