Fixing wmi issue when device detection thread run nth time
This commit is contained in:
parent
b49edaafb0
commit
1053b83782
1 changed files with 8 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue