本文介绍了如何获取Win32_OperatingSystem.LastBootUpTime的datetime格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用Win32_OperatingSystem类(WMI)获取LastBootUpTime。

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);

我想将此时间写入CTime或COleDateTime变量。但是变量vtProp有BSTR类型,看起来像 20100302185848.499768 + 300
任何WMI类的任何datetime属性都有BSTR类型

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

我可以把WMI类的datetime属性到CTime?

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

但是如何在C ++中使用SWbemDateTime.GetVarDate在MSDN中只是这个函数的脚本示例

But how use SWbemDateTime.GetVarDate() in C++? In MSDN just scripting sample for this function

推荐答案

你必须做一些解析来转换。格式为yyyyMMddhhmmss.ffffff + zzz(zzz是UTC偏移量(以分钟为单位))。 可以它为你。

You'll have to do some parsing to convert it. The format is yyyyMMddhhmmss.ffffff+zzz (zzz is UTC offset in minutes). The SWbemDateTime.GetVarDate() method can do it for you.

这篇关于如何获取Win32_OperatingSystem.LastBootUpTime的datetime格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 00:16