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


C++ SystemInfo类代码示例

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


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

示例1:

int64
ClipboardSizeDataSource::NextValue(SystemInfo& info)
{
	if (fText)
		return info.ClipboardTextSize()/* / 1024*/;
	return info.ClipboardSize()/* / 1024*/;
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:7,代码来源:DataSource.cpp

示例2: double

int64
PageFaultsDataSource::NextValue(SystemInfo& info)
{
	uint64 faults = info.PageFaults();

	int64 faultsPerSecond = uint64(1024 * double(faults - fPreviousFaults)
		/ (info.Time() - fPreviousTime) * 1000000.0);

	fPreviousFaults = faults;
	fPreviousTime = info.Time();

	return faultsPerSecond;
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:13,代码来源:DataSource.cpp

示例3: CpuInfoInPdh

Json::Value GenerateJsonData::GetPerformanceData()
{ 
	CpuInfoInPdh *cpu = new CpuInfoInPdh();

	MemoryInfo	*mem = new MemoryInfo();

	SystemInfo *sys = new SystemInfo();

	DiskInfo	*disk = new DiskInfo();
	disk->GetDefaultDriveFixedSize();

	NetInterfaceInfo *net = new NetInterfaceInfo();
	
	Json::Value root;
	
	Json::Value json_mem;
	Json::Value json_disk;
	Json::Value json_net;

	root["time"] = Json::Value((Json::Value::UInt64)sys->GetTimeGMT());
	
	root["vmid"] = "windows-vmid";
	
	root["cpu"] = Json::Value((Json::Value::UInt)cpu->GetCpuUsedRate());

	json_mem["total"] = Json::Value((Json::Value::UInt64)mem->GetTotalPhysMemSize());
	json_mem["used"] = Json::Value((Json::Value::UInt64)mem->GetUsedPhysMemSize());

	root["mem"] = json_mem;
		
	json_disk["total"] = Json::Value((Json::Value::UInt64)disk->GetDisk_C_TotalFixdSize());
	json_disk["used"] = Json::Value((Json::Value::UInt64)disk->GetDisk_C_UsedFixedSize());
	json_disk["read"] = Json::Value((Json::Value::UInt64)disk->GetDiskReadSpeed());
	json_disk["write"] = Json::Value((Json::Value::UInt64)disk->GetDiskWriteSpeed());

	root["disk"] = json_disk;

	json_net["in"] = Json::Value((Json::Value::UInt64)net->GetNetReceivedSpeed());
	json_net["out"] = Json::Value((Json::Value::UInt64)net->GetNetSendSpeed());

	root["net"] = json_net;

	
	Json::StyledWriter styled_writer;
	cout << styled_writer.write(root) << endl;
		
	return root;
}
开发者ID:MasterHuang0804,项目名称:SystemMonitor-Windows,代码行数:48,代码来源:GenerateJsonData.cpp

示例4: GetCaption

/**
   Return the Description for the OS, usually the same as caption.

   \returns     Description for OS, intended for display/human reader
   \throws      SCXCoreLib::SCXNotSupportedException - if not implemented for the platform
(passed through from GetCaption().

*/
std::wstring SCXOSTypeInfo::GetDescription() const
{
    std::wstring str = GetCaption();

#if defined(sun)
    bool isInGlobalZone = false;
    SystemInfo si;

    // True means platform has zone support, false means does not
    if(si.GetSUN_IsInGlobalZone(isInGlobalZone))
    {
        if(isInGlobalZone)
            str += L" Global Zone";
        else
            str += L" Non-Global Zone";
    }
#endif
    return str;
}
开发者ID:Microsoft,项目名称:pal,代码行数:27,代码来源:scxostypeinfo.cpp

示例5: uname

status_t
LocalDebuggerInterface::GetSystemInfo(SystemInfo& info)
{
	system_info sysInfo;
	status_t result = get_system_info(&sysInfo);
	if (result != B_OK)
		return result;

	utsname name;
	result = uname(&name);
	if (result != B_OK)
		return result;

	info.SetTo(fTeamID, sysInfo, name);
	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:16,代码来源:LocalDebuggerInterface.cpp

示例6: GetSystems

  Status GetSystems(ServerContext* /*context*/, const Empty* /*request*/, ServerWriter<SystemType>* writer) override {
    auto _api = this->options.GetAPI();

    for (auto systems : _api) {
      SystemType system;

      system.set_name(systems.first);

      for (auto&& subsystem : systems.second) {
        SystemInfo* subInfo = system.add_subsystems();

        std::ifstream ifabout(subsystem, std::ios_base::in);
        if (!ifabout.is_open()) continue;

        ey_data about = parse_eyaml(ifabout, subsystem);

        std::string name = about.get("name");
        std::string id = about.get("identifier");
        std::string desc = about.get("description");
        std::string author = about.get("author");
        std::string target = about.get("target-platform");

        if (id.empty())
          id = about.get("id"); // allow alias
        if (id.empty()) {
          // compilers use filename minus ext as id
          boost::filesystem::path ey(subsystem);
          id = ey.stem().string();
        }

        // allow author alias used by compiler descriptors
        if (author.empty())
          author = about.get("maintainer");

        subInfo->set_name(name);
        subInfo->set_id(id);
        subInfo->set_description(desc);
        subInfo->set_author(author);
        subInfo->set_target(target);
      }

      writer->Write(system);
    }

    return Status::OK;
  }
开发者ID:enigma-dev,项目名称:enigma-dev,代码行数:46,代码来源:Server.cpp

示例7: defined

    /**
       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

示例8: main

int main(int argc, char* argv[])
{
    SystemInfo sysInfo;
    TCHAR szServicePack[128] = { 0 };

    switch (sysInfo.getWindowsVersion())
    {
    case Windows:
        cout << "Windows" << endl;
        break;

    case Windows32s:
        cout << "Windows 32s" << endl;
        break;

    case Windows95:
        cout << "Windows 95" << endl;
        break;

    case Windows95OSR2:
        cout << "Windows 95 SR2" << endl;
        break;

    case Windows98:
        cout << "Windows 98" << endl;
        break;

    case Windows98SE:
        cout << "Windows 98 SE" << endl;
        break;

    case WindowsMillennium:
        cout << "Windows Me" << endl;
        break;

    case WindowsNT351:
        cout << "Windows NT 3.51" << endl;
        break;

    case WindowsNT40:
        cout << "Windows NT 4.0" << endl;
        break;

    case WindowsNT40Server:
        cout << "Windows NT 4.0 Server" << endl;
        break;

    case Windows2000:
        cout << "Windows 2000" << endl;
        break;

    case WindowsXP:
        cout << "Windows XP" << endl;
        break;

    case WindowsXPProfessionalx64:
        cout << "Windows XP Professional x64" << endl;
        break;

    case WindowsHomeServer:
        cout << "Windows Home Server" << endl;
        break;

    case WindowsServer2003:
        cout << "Windows Server 2003" << endl;
        break;

    case WindowsServer2003R2:
        cout << "Windows Server 2003 R2" << endl;
        break;

    case WindowsVista:
        cout << "Windows Vista" << endl;
        break;

    case WindowsServer2008:
        cout << "Windows Server 2008" << endl;
        break;

    case WindowsServer2008R2:
        cout << "Windows Server 2008 R2" << endl;
        break;

    case Windows7:
        cout << "Windows 7" << endl;
        break;
    case Windows8Point1:
        cout << "Windows 8.1" << endl;

    case Windows10:
        cout << "Windows 10 ";
        break;

    case WindowsServer2016TechnicalPreview:
        cout << "Windows 10 Server" << endl;
        break;
    }

    switch (sysInfo.getWindowsEdition())
    {
//.........这里部分代码省略.........
开发者ID:yiminyangguang520,项目名称:HardwareInfoUtils,代码行数:101,代码来源:SystemVersion.cpp

示例9: 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

示例10: locker

status_t
DebugReportGenerator::_GenerateReportHeader(BFile& _output)
{
	AutoLocker< ::Team> locker(fTeam);

	BString data;
	data.SetToFormat("Debug information for team %s (%" B_PRId32 "):\n",
		fTeam->Name(), fTeam->ID());
	WRITE_AND_CHECK(_output, data);

	cpu_platform platform = B_CPU_UNKNOWN;
	cpu_vendor cpuVendor = B_CPU_VENDOR_UNKNOWN;
	uint32 cpuModel = 0;
	uint32 topologyNodeCount = 0;
	cpu_topology_node_info* topology = NULL;
	get_cpu_topology_info(NULL, &topologyNodeCount);
	if (topologyNodeCount != 0) {
		topology = new(std::nothrow) cpu_topology_node_info[topologyNodeCount];
		if (topology == NULL)
			return B_NO_MEMORY;

		BPrivate::ArrayDeleter<cpu_topology_node_info> deleter(topology);
		get_cpu_topology_info(topology, &topologyNodeCount);

		for (uint32 i = 0; i < topologyNodeCount; i++) {
			switch (topology[i].type) {
				case B_TOPOLOGY_ROOT:
					platform = topology[i].data.root.platform;
					break;

				case B_TOPOLOGY_PACKAGE:
					cpuVendor = topology[i].data.package.vendor;
					break;

				case B_TOPOLOGY_CORE:
					cpuModel = topology[i].data.core.model;
					break;

				default:
					break;
			}
		}
	}

	SystemInfo sysInfo;
	if (fDebuggerInterface->GetSystemInfo(sysInfo) == B_OK) {
		const system_info &info = sysInfo.GetSystemInfo();
		data.SetToFormat("CPU(s): %" B_PRId32 "x %s %s\n",
			info.cpu_count, get_cpu_vendor_string(cpuVendor),
			get_cpu_model_string(platform, cpuVendor, cpuModel));
		WRITE_AND_CHECK(_output, data);

		char maxSize[32];
		char usedSize[32];

		data.SetToFormat("Memory: %s total, %s used\n",
			BPrivate::string_for_size((int64)info.max_pages * B_PAGE_SIZE,
				maxSize, sizeof(maxSize)),
			BPrivate::string_for_size((int64)info.used_pages * B_PAGE_SIZE,
				usedSize, sizeof(usedSize)));
		WRITE_AND_CHECK(_output, data);

		const utsname& name = sysInfo.GetSystemName();
		data.SetToFormat("Haiku revision: %s (%s)\n", name.version,
			name.machine);
		WRITE_AND_CHECK(_output, data);
	}

	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:70,代码来源:DebugReportGenerator.cpp

示例11: _

status_t
ActivityView::AddDataSource(const DataSource* source, const BMessage* state)
{
	if (source == NULL)
		return B_BAD_VALUE;

	BAutolock _(fSourcesLock);

	// Search for the correct insert spot to maintain the order of the sources
	int32 insert = DataSource::IndexOf(source);
	for (int32 i = 0; i < fSources.CountItems() && i < insert; i++) {
		DataSource* before = fSources.ItemAt(i);
		if (DataSource::IndexOf(before) > insert) {
			insert = i;
			break;
		}
	}
	if (insert > fSources.CountItems())
		insert = fSources.CountItems();

	// Generate DataHistory and ViewHistory objects for the source
	// (one might need one history per CPU)

	uint32 count = 1;
	if (source->PerCPU()) {
		SystemInfo info;
		count = info.CPUCount();
	}

	for (uint32 i = 0; i < count; i++) {
		DataHistory* values = new(std::nothrow) DataHistory(10 * 60000000LL,
			RefreshInterval());
		ListAddDeleter<DataHistory> valuesDeleter(fValues, values, insert);

		ViewHistory* viewValues = new(std::nothrow) ViewHistory;
		ListAddDeleter<ViewHistory> viewValuesDeleter(fViewValues, viewValues,
			insert);

		if (valuesDeleter.Failed() || viewValuesDeleter.Failed())
			return B_NO_MEMORY;

		values->SetScale(_ScaleFor(source->ScaleType()));

		DataSource* copy;
		if (source->PerCPU())
			copy = source->CopyForCPU(i);
		else
			copy = source->Copy();

		ListAddDeleter<DataSource> sourceDeleter(fSources, copy, insert);
		if (sourceDeleter.Failed())
			return B_NO_MEMORY;

		BString colorName = source->Name();
		colorName << " color";
		if (state != NULL) {
			const rgb_color* color = NULL;
			ssize_t colorLength;
			if (state->FindData(colorName.String(), B_RGB_COLOR_TYPE, i,
					(const void**)&color, &colorLength) == B_OK
				&& colorLength == sizeof(rgb_color))
				copy->SetColor(*color);
		}

		valuesDeleter.Detach();
		viewValuesDeleter.Detach();
		sourceDeleter.Detach();
		insert++;
	}

#ifdef __HAIKU__
	InvalidateLayout();
#endif
	return B_OK;
}
开发者ID:,项目名称:,代码行数:75,代码来源:

示例12: Looper

void
ActivityView::MouseDown(BPoint where)
{
	int32 buttons = B_SECONDARY_MOUSE_BUTTON;
	if (Looper() != NULL && Looper()->CurrentMessage() != NULL)
		Looper()->CurrentMessage()->FindInt32("buttons", &buttons);

	if (buttons == B_PRIMARY_MOUSE_BUTTON) {
		fZoomPoint = where;
		fOriginalResolution = fDrawResolution;
		fZooming = true;
		SetMouseEventMask(B_POINTER_EVENTS);
		return;
	}

	BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
	menu->SetFont(be_plain_font);

	BMenu* additionalMenu = new BMenu(B_TRANSLATE("Additional items"));
	additionalMenu->SetFont(be_plain_font);

	SystemInfo info;
	BMenuItem* item;

	for (int32 i = 0; i < DataSource::CountSources(); i++) {
		const DataSource* source = DataSource::SourceAt(i);

		if (source->MultiCPUOnly() && info.CPUCount() == 1)
			continue;

		BMessage* message = new BMessage(kMsgToggleDataSource);
		message->AddInt32("index", i);

		item = new BMenuItem(source->Name(), message);
		if (FindDataSource(source))
			item->SetMarked(true);

		if (source->Primary())
			menu->AddItem(item);
		else
			additionalMenu->AddItem(item);
	}

	menu->AddItem(new BMenuItem(additionalMenu));
	menu->AddSeparatorItem();
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show legend"),
		new BMessage(kMsgToggleLegend)));
	item->SetMarked(fShowLegend);

	menu->SetTargetForItems(this);
	additionalMenu->SetTargetForItems(this);

	ActivityWindow* window = dynamic_cast<ActivityWindow*>(Window());
	if (window != NULL && window->ActivityViewCount() > 1) {
		menu->AddSeparatorItem();
		BMessage* message = new BMessage(kMsgRemoveView);
		message->AddPointer("view", this);
		menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove graph"),
			message));
		item->SetTarget(window);
	}

	ConvertToScreen(&where);
	menu->Go(where, true, false, true);
}
开发者ID:,项目名称:,代码行数:65,代码来源:


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