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


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

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


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

示例1: GetArchitectureString

    /**
       Returns the architecture of the platform, e.g. PA-Risc, x86 or SPARC
    
       \returns   String with the architecture of the platform
    
    */
    std::wstring SCXOSTypeInfo::GetArchitectureString() const
    {
#if defined(hpux)
#if defined(hppa)
        return L"PA-Risc";
#else
        return L"IA64";
#endif // defined(hpux)

#elif defined(linux)

        unsigned short bitSize = 0;
        try
        {
            SystemInfo sysInfo;
            sysInfo.GetNativeBitSize(bitSize);
        }
        catch (SCXCoreLib::SCXException &e)
        {
            SCX_LOGERROR(m_log, StrAppend( StrAppend(L"Failure in SystemInstance::GetNativeBitSize: ", e.What()), e.Where()));
        }

        if (32 == bitSize)
        {
            return L"x86";
        }
        else if (64 == bitSize) 
        {
            return L"x64";
        }
        else 
        {
            assert(!"Unknown architecture");
            return L"Unknown";
        }

#elif defined(sun)
            
#if defined(sparc)
        return L"SPARC";
#else
        return L"x86";
#endif
        
#elif defined(aix)
        return L"powerpc";     // This is what uname -p says
        
#elif defined(macos)

        // On MacOS Intel platforms, the architecture appears to always be i386,
        // regardless of 32-bit vs. 64-bit capabilities.  However, since we may
        // (some day) run on something else, we'll implement this properly.
        //
        // Intel (i386) on Mac is a special case: we return 'x86' or 'x64' based
        // on 64-bit capabilities of the CPU.

        // First get the machine architecture dynamically

        int mib[2];
        char hwMachine[64];
        size_t len_hwMachine = sizeof(hwMachine);

        mib[0] = CTL_HW;
        mib[1] = HW_MACHINE;

        if (0 != sysctl(mib, 2, hwMachine, &len_hwMachine, NULL, 0))
        {
            wostringstream sout;
            sout << L"Failure calling sysctl(): Errno=" << errno;
            SCX_LOGERROR(m_log, sout.str());

            return L"";
        }

        // Now figure out our bit size (if Intel, handle the special case)

        if (0 == strncmp("i386", hwMachine, sizeof(hwMachine)))
        {
            unsigned short bitSize = 0;
            try
            {
                SystemInfo sysInfo;
                sysInfo.GetNativeBitSize(bitSize);
            }
            catch (SCXCoreLib::SCXException &e)
            {
                SCX_LOGERROR(m_log, StrAppend( StrAppend(L"Failure in SystemInstance::GetNativeBitSize: ", e.What()), e.Where()));
            }

            if (32 == bitSize)
            {
                return L"x86";
            }
            else if (64 == bitSize) 
//.........这里部分代码省略.........
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:101,代码来源:scxostypeinfo.cpp

示例2: EnumerateOneInstance


//.........这里部分代码省略.........
        //      OverwritePolicy
        //      Distributed

        /* CSCreationClassName is a key property and thus set in AddKeys */
        /* CSName is a key property and thus set in AddKeys */
        /* CreationClassName is a key property and thus set in AddKeys */

        if (osinst->GetOSType(Aunsignedshort))
            inst.OSType_value( Aunsignedshort );

        if (osinst->GetOtherTypeDescription(Awstring))
            inst.OtherTypeDescription_value( StrToMultibyte(Awstring).c_str() );

        if (osinst->GetVersion(Awstring))
            inst.Version_value( StrToMultibyte(Awstring).c_str() );

        if (osinst->GetLastBootUpTime(ASCXCalendarTime))
        {
            MI_Datetime bootTime;
            CIMUtils::ConvertToCIMDatetime( bootTime, ASCXCalendarTime );
            inst.LastBootUpTime_value( bootTime );
        }

        if (osinst->GetLocalDateTime(ASCXCalendarTime))
        {
            MI_Datetime localTime;
            CIMUtils::ConvertToCIMDatetime( localTime, ASCXCalendarTime );
            inst.LocalDateTime_value( localTime );
        }

        if (osinst->GetCurrentTimeZone(Ashort))
            inst.CurrentTimeZone_value( Ashort );

        if (osinst->GetNumberOfLicensedUsers(Auint))
            inst.NumberOfLicensedUsers_value( Auint );

        if (osinst->GetNumberOfUsers(Auint))
            inst.NumberOfUsers_value( Auint );

        if (ProcessEnumeration::GetNumberOfProcesses(Auint))
            inst.NumberOfProcesses_value( Auint );

        if (osinst->GetMaxNumberOfProcesses(Auint))
            inst.MaxNumberOfProcesses_value( Auint );

        if (meminst->GetTotalSwap(Ascxulong))
        {
            inst.TotalSwapSpaceSize_value( BytesToKiloBytes(Ascxulong) );
        }

        if (meminst->GetTotalPhysicalMemory(Ascxulong) && meminst->GetTotalSwap(Ascxulong1))
        {
            inst.TotalVirtualMemorySize_value( BytesToKiloBytes(Ascxulong) + BytesToKiloBytes(Ascxulong1) );
        }

        if (meminst->GetAvailableMemory(Ascxulong))
        {
            Ascxulong = BytesToKiloBytes(Ascxulong);

            if (meminst->GetAvailableSwap(Ascxulong1)) {
                inst.FreeVirtualMemory_value( Ascxulong + BytesToKiloBytes(Ascxulong1) );
            }

            inst.FreePhysicalMemory_value( Ascxulong );
        }

        if (meminst->GetTotalPhysicalMemory(Ascxulong))
            inst.TotalVisibleMemorySize_value( BytesToKiloBytes(Ascxulong) );

        if (meminst->GetTotalSwap(Ascxulong))
            inst.SizeStoredInPagingFiles_value( BytesToKiloBytes(Ascxulong) );

        if (meminst->GetAvailableSwap(Ascxulong))
            inst.FreeSpaceInPagingFiles_value( BytesToKiloBytes(Ascxulong) );

        if (osinst->GetMaxProcessMemorySize(Ascxulong))
            inst.MaxProcessMemorySize_value( Ascxulong );

        if (osinst->GetMaxProcessesPerUser(Auint))
            inst.MaxProcessesPerUser_value( Auint );

        /*===================================================================================*/
        /* Properties of SCX_OperatingSystem (Taken from PG_OperatingSystem)                 */
        /*===================================================================================*/

        SystemInfo sysInfo;
        if (sysInfo.GetNativeBitSize(Aunsignedshort))
        {
            std::ostringstream bitText;
            bitText << Aunsignedshort << " bit";

            inst.OperatingSystemCapability_value( bitText.str().c_str() );
        }

        if (osinst->GetSystemUpTime(Ascxulong))
            inst.SystemUpTime_value( Ascxulong );
    }

    context.Post(inst);
}
开发者ID:Microsoft,项目名称:SCXcore,代码行数:101,代码来源:SCX_OperatingSystem_Class_Provider.cpp


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