当前位置: 首页>>代码示例>>C++>>正文


C++ SystemInfo::GetVirtualMachineState方法代码示例

本文整理汇总了C++中SystemInfo::GetVirtualMachineState方法的典型用法代码示例。如果您正苦于以下问题:C++ SystemInfo::GetVirtualMachineState方法的具体用法?C++ SystemInfo::GetVirtualMachineState怎么用?C++ SystemInfo::GetVirtualMachineState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SystemInfo的用法示例。


在下文中一共展示了SystemInfo::GetVirtualMachineState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EnumerateOneInstance

MI_BEGIN_NAMESPACE

static void EnumerateOneInstance(
    Context& context,
    SCX_Agent_Class& inst,
    bool keysOnly)
{
    // Fill in the key
    inst.Name_value("scx");

    if ( !keysOnly )
    {
        inst.Caption_value("SCX Agent meta-information");

        //
        // Populate properties regarding the agent's build number
        // 
        stringstream ss;

        ss << SCX_BUILDVERSION_MAJOR << "." << SCX_BUILDVERSION_MINOR << "." << SCX_BUILDVERSION_PATCH << "-" << SCX_BUILDVERSION_BUILDNR;

        inst.VersionString_value( ss.str().c_str() );
        inst.MajorVersion_value( static_cast<unsigned short>(SCX_BUILDVERSION_MAJOR) );
        inst.MinorVersion_value( static_cast<unsigned short>(SCX_BUILDVERSION_MINOR) );
        inst.RevisionNumber_value( static_cast<unsigned short>(SCX_BUILDVERSION_PATCH) );
        inst.BuildNumber_value( static_cast<unsigned short>(SCX_BUILDVERSION_BUILDNR) );

        string strDesc;
        strDesc = StrToMultibyte(StrAppend(StrAppend(SCX_BUILDVERSION_STATUS, L" - "), SCX_BUILDVERSION_DATE));
        inst.Description_value( strDesc.c_str() );

        string installVersion;
        MI_Datetime installTime;
        if ( SCXCore::g_MetaProvider.GetInstallInfoData(installVersion, installTime) )
        {
            inst.KitVersionString_value( installVersion.c_str() );
            // provide standard property as "date-time"
            inst.InstallDate_value( installTime );
        }

        // 
        // Populate the build date - the value is looked up by constructor
        //
        string buildTime;
        if ( SCXCore::g_MetaProvider.GetBuildTime(buildTime) )
        {
            inst.BuildDate_value( buildTime.c_str() );
        }

        // 
        // Populate the hostname date - the value is cached internally in the MachnieInfo code.
        //
        try {
            NameResolver mi;
            inst.Hostname_value( StrToMultibyte(mi.GetHostDomainname()).c_str() );
        } catch (SCXException& e) {
            SCX_LOGWARNING( SCXCore::g_MetaProvider.GetLogHandle(), StrAppend(
                                StrAppend(L"Can't read host/domainname because ", e.What()),
                                e.Where()));
        }


        // 
        // Populate name, version and alias for the OS 
        //

        // Keep an instance of class with static information about OS type
        static SCXSystemLib::SCXOSTypeInfo  osTypeInfo;
        inst.OSName_value( StrToMultibyte(osTypeInfo.GetOSName()).c_str() );
        inst.OSVersion_value( StrToMultibyte(osTypeInfo.GetOSVersion()).c_str() );
        inst.OSAlias_value( StrToMultibyte(osTypeInfo.GetOSAlias()).c_str() );
        inst.OSType_value( StrToMultibyte(osTypeInfo.GetOSFamilyString()).c_str() );
        inst.Architecture_value( StrToMultibyte(osTypeInfo.GetArchitectureString()).c_str() );

        // 
        // This property contains the architecture as uname reports it
        // 
        inst.UnameArchitecture_value( StrToMultibyte(osTypeInfo.GetUnameArchitectureString()).c_str() );

        // 
        // Set property indicating what the lowest log level currently in effect for 
        // the agent is
        // 
        inst.MinActiveLogSeverityThreshold_value(
            StrToMultibyte(SCXCoreLib::SCXLogHandleFactory::GetLogConfigurator()->GetMinActiveSeverityThreshold()).c_str() );

        //
        // Populate the type of machine this is (Physical, Virtual, or Unknown)
        //
        try {
            SystemInfo sysInfo;

            eVmType vmType;
            sysInfo.GetVirtualMachineState(vmType);

            string vmText;
            switch (vmType)
            {
                case eVmDetected:
                    vmText = "Virtual";
//.........这里部分代码省略.........
开发者ID:Microsoft,项目名称:SCXcore,代码行数:101,代码来源:SCX_Agent_Class_Provider.cpp


注:本文中的SystemInfo::GetVirtualMachineState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。