How get Win32_OperatingSystem.LastBootUpTime in datetime format

Posted by chekalin-v on Stack Overflow See other posts from Stack Overflow or by chekalin-v
Published on 2010-03-16T09:27:04Z Indexed on 2010/03/16 9:46 UTC
Read the original article Hit count: 500

Filed under:
|

I have been trying to get LastBootUpTime using Win32_OperatingSystem class (WMI).

HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, 
        &pclsObj, &uReturn);

    if(0 == uReturn)
    {
        break;
    }

    VARIANT vtProp;

    // Get the value of the Name property
    hr = pclsObj->Get(L"LastBootUpTime", 0, &vtProp, 0, 0);          
    VariantClear(&vtProp);

I want to write this time to CTime or COleDateTime variable. But variable vtProp has BSTR type and look like 20100302185848.499768+300 Also any datetime property of any WMI class have BSTR type

How can I put datetime property of WMI class to CTime?

© Stack Overflow or respective owner

Related posts about wmi

Related posts about c++