Fixing wmi issue when device detection thread run nth time

This commit is contained in:
Alex 2021-06-17 04:46:10 +02:00 committed by Adam Honse
parent b49edaafb0
commit 1053b83782

View file

@ -147,6 +147,14 @@ HRESULT Wmi::query(std::string queryStr, std::vector<QueryObj>& queryVectorOut,
int nIdx = 0;
IEnumWbemClassObject* pEnumerator = nullptr;
// Initialize COM. ------------------------------------------
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
return hres;
}
pSvc->Release();
// Reconnect to server before each query as we were seeing disconnected failures
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace