6

Referring to MSDN i modify abit the code so i can retrieve HDD Serial Number

hres = pSvc->ExecQuery(
    bstr_t("WQL"),
    bstr_t("SELECT SerialNumber FROM Win32_PhysicalMedia"),
    WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 
    NULL,
    &pEnumerator);
..
..<other code here>
..
hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0);

I convert vtProp.bstrVal to std::wstring and do a reverse string, the reason i have to reverse the result from vtProp.bstrVal is because i found that some of the computer i use to retrieve serial number is in wrong order

For example: Computer 1 return serial: W[space]-DXW1M6EC01056, i have to do a reverse string to make it [space]WD-WXM1E60C0165 which is correct after compare with label on the HDD

but when i test with Computer 2 return serial: WD-WXM1E60C0165 (i use the same code, it actually return correctly when i check with the serial label on the HDD) if my code do a reverse string, it will become W[space]-DXW1M6EC01056

I check with both computer, it is Little-Endian, i do not know whether it has something to do with Endianness or not.

Is there anything making the return result in different order? HDD maker/brand? I run the program in Windows XP Pro for all test result.

4