MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / query

Method query

wmi/wmi.cpp:140–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140HRESULT Wmi::query(std::string queryStr, std::vector<QueryObj>& queryVectorOut, const AdditionalFilters* filters)
141{
142 if (pSvc == nullptr)
143 {
144 return E_FAIL;
145 }
146
147 HRESULT hres;
148 int nIdx = 0;
149 IEnumWbemClassObject* pEnumerator = nullptr;
150
151 // Initialize COM. ------------------------------------------
152 hres = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
153 if (FAILED(hres))
154 {
155 return hres;
156 }
157
158 pSvc->Release();
159 // Reconnect to server before each query as we were seeing disconnected failures
160 hres = pLoc->ConnectServer(
161 _bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
162 nullptr, // User name. NULL = current user
163 nullptr, // User password. NULL = current
164 nullptr, // Locale. NULL indicates current
165 0, // Security flags.
166 nullptr, // Authority (for example, Kerberos)
167 nullptr, // Context object
168 &pSvc // pointer to IWbemServices proxy
169 );
170
171 // Make the WMI query
172 hres = pSvc->ExecQuery(
173 bstr_t("WQL"),
174 bstr_t(queryStr.c_str()),
175 WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
176 nullptr,
177 &pEnumerator
178 );
179
180 if (FAILED(hres))
181 {
182 return hres;
183 }
184
185 IWbemClassObject* pclsObj = nullptr;
186 ULONG uReturn = 0;
187
188 while (pEnumerator)
189 {
190 hres = pEnumerator->Next(WMI_WAIT_TIME, 1, &pclsObj, &uReturn);
191
192 if (0==uReturn)
193 {
194 break;
195 }
196
197 VARIANT vtProp;

Callers 4

i2c_smbus_i801_detectFunction · 0.80
i2c_smbus_piix4_detectFunction · 0.80
DMIInfoMethod · 0.80

Calls 4

utf8_decodeFunction · 0.85
utf8_encodeFunction · 0.85
GetMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected