Commit

r57280:513868ae7af6 public

Description:

Windows: Handle systems where WMI does not return a serial as BSTR (which means it refuses to/cannot return a serial at all).

Commit status:

[Not Reviewed]

References:

Comments:

0 Commit comments 0 Inline Comments

Unresolved TODOs:

There are no unresolved TODOs

Author

-
Add another comment

r57280:513868ae7af6 -

@@ -217,6 +217,20
217
217
218 // Get the value of the Name property
218 // Get the value of the Name property
219 hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0);
219 hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0);
220
221 // <FS:ND> On some systems it can happen that the serial is either unset or does not return a string.
222 // In that case try to get the next enumator and try again.
223 // Without this condition the viewer will crash. With it at worst the affected system will use 0*16 as the machineid.
224 if( FAILED(hr) || !vtProp.bstrVal || vtProp.vt != VT_BSTR )
225 {
226 std::stringstream strHr;
227 strHr << std::hex << hr;
228 LL_WARNS() << "pclsObj->Get(L'SerialNumber') failed with hr" << strHr.str().c_str() << " and vtProp.vt = " << (U32)vtProp.vt << LL_ENDL;
229 pclsObj->Release();
230 continue;
231 }
232 // </FS:ND>
233
220 LL_INFOS("AppInit") << " Serial Number : " << vtProp.bstrVal << LL_ENDL;
234 LL_INFOS("AppInit") << " Serial Number : " << vtProp.bstrVal << LL_ENDL;
221 // use characters in the returned Serial Number to create a byte array of size len
235 // use characters in the returned Serial Number to create a byte array of size len
222 BSTR serialNumber ( vtProp.bstrVal);
236 BSTR serialNumber ( vtProp.bstrVal);
You need to be logged in to leave comments. Login now