Skip to content

Commit ee21487

Browse files
xQwexxCalcProgrammer1
authored andcommitted
Fixing wmi issue when device detection thread run nth time
1 parent 8852f3f commit ee21487

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

wmi/wmi.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ HRESULT Wmi::query(std::string queryStr, std::vector<QueryObj>& queryVectorOut,
147147
int nIdx = 0;
148148
IEnumWbemClassObject* pEnumerator = nullptr;
149149

150+
// Initialize COM. ------------------------------------------
151+
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
152+
if (FAILED(hres))
153+
{
154+
return hres;
155+
}
156+
157+
pSvc->Release();
150158
// Reconnect to server before each query as we were seeing disconnected failures
151159
hres = pLoc->ConnectServer(
152160
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace

0 commit comments

Comments
 (0)