• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GlobalMemoryStatusEx函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Sys_LowPhysicalMemory

/*
==================
Sys_LowPhysicalMemory
==================
*/
qboolean Sys_LowPhysicalMemory() 
{
	static MEMORYSTATUSEX stat;
	static qboolean bAsked = qfalse;
	static cvar_t* sys_lowmem = Cvar_Get( "sys_lowmem", "0", 0 );

	if (!bAsked)	// just in case it takes a little time for GlobalMemoryStatus() to gather stats on
	{				//	stuff we don't care about such as virtual mem etc.
		bAsked = qtrue;
		GlobalMemoryStatusEx (&stat);
	}
	if (sys_lowmem->integer)
	{
		return qtrue;
	}
	return (stat.ullTotalPhys <= MEM_THRESHOLD) ? qtrue : qfalse;
}
开发者ID:shadow95,项目名称:OpenJK,代码行数:22,代码来源:win_main.cpp


示例2: sizeof

/////////////////////////////////////////////////////////////////////
// GetMemoryInfo => 메모리에 대한 정보를 얻어온다. (단위 MB)
// dwTotalMemMB : 시스템 전체 메모리 용량
// dwAvailMemMB : 사용중인 메모리 용량
// dwVirtualMemMB : 가상메모리 전체 용량
/////////////////////////////////////////////////////////////////////
void MBMatchSystemInfo::GetMemoryInfo(DWORD* dwTotalMemMB, DWORD* dwAvailMemMB, DWORD* dwVirtualMemMB)
{
#ifdef _MONITORING
	MEMORYSTATUSEX statex;
	statex.dwLength = sizeof(statex);
	GlobalMemoryStatusEx(&statex);

	DWORDLONG lMemTotalMB = (statex.ullTotalPhys / (1024 * 1024));
	*dwTotalMemMB = (DWORD)lMemTotalMB;

	DWORDLONG lAvailMemMB = (statex.ullAvailPhys / (1024 * 1024));
	*dwAvailMemMB = (DWORD)lAvailMemMB;

	DWORDLONG lVirtualMemMB = (statex.ullTotalVirtual / (1024 * 1024));
	*dwVirtualMemMB = (DWORD)lVirtualMemMB;
#endif
}
开发者ID:roseon,项目名称:life-marvelous,代码行数:23,代码来源:MBMatchSystemInfo.cpp


示例3: getPhysicalMemorySize

/* Returns 0 if physical memory size cannot be identified */
StgWord64 getPhysicalMemorySize (void)
{
    static StgWord64 physMemSize = 0;
    if (!physMemSize) {
        MEMORYSTATUSEX status;
        status.dwLength = sizeof(status);
        if (!GlobalMemoryStatusEx(&status)) {
#if defined(DEBUG)
            errorBelch("warning: getPhysicalMemorySize: cannot get physical "
                       "memory size");
#endif
            return 0;
        }
        physMemSize = status.ullTotalPhys;
    }
    return physMemSize;
}
开发者ID:AaronFriel,项目名称:ghc,代码行数:18,代码来源:OSMem.c


示例4: physical_ram

	boost::uint64_t physical_ram()
	{
		boost::uint64_t ret = 0;
		// figure out how much physical RAM there is in
		// this machine. This is used for automatically
		// sizing the disk cache size when it's set to
		// automatic.
#ifdef TORRENT_BSD
#ifdef HW_MEMSIZE
		int mib[2] = { CTL_HW, HW_MEMSIZE };
#else
		// not entirely sure this sysctl supports 64
		// bit return values, but it's probably better
		// than not building
		int mib[2] = { CTL_HW, HW_PHYSMEM };
#endif
		size_t len = sizeof(ret);
		if (sysctl(mib, 2, &ret, &len, NULL, 0) != 0)
			ret = 0;
#elif defined TORRENT_WINDOWS
		MEMORYSTATUSEX ms;
		ms.dwLength = sizeof(MEMORYSTATUSEX);
		if (GlobalMemoryStatusEx(&ms))
			ret = ms.ullTotalPhys;
		else
			ret = 0;
#elif defined TORRENT_LINUX
		ret = sysconf(_SC_PHYS_PAGES);
		ret *= sysconf(_SC_PAGESIZE);
#elif defined TORRENT_AMIGA
		ret = AvailMem(MEMF_PUBLIC);
#endif

#if TORRENT_USE_RLIMIT
		if (ret > 0)
		{
			struct rlimit r;
			if (getrlimit(RLIMIT_AS, &r) == 0 && r.rlim_cur != RLIM_INFINITY)
			{
				if (ret > r.rlim_cur)
					ret = r.rlim_cur;
			}
		}
#endif
		return ret;
	}
开发者ID:steeve,项目名称:libtorrent,代码行数:46,代码来源:disk_buffer_pool.cpp


示例5: defined

/*==========================================================================*/
size_t SystemInformation::TotalMemorySize()
{
// Windows
#if defined ( KVS_PLATFORM_WINDOWS )
#if defined ( KVS_PLATFORM_CPU_64 )
    MEMORYSTATUSEX memstat;
    GlobalMemoryStatusEx( &memstat );
    return memstat.ullTotalPhys;
#else
    MEMORYSTATUS memstat;
    GlobalMemoryStatus( &memstat );
    return memstat.dwTotalPhys;
#endif

// Linux
#elif defined ( KVS_PLATFORM_LINUX ) || defined ( KVS_PLATFORM_CYGWIN )
    long phys_page_size = sysconf( _SC_PHYS_PAGES );
    kvsMessageWarning( phys_page_size != -1,
                       ::GetWarningMessage( errno, "_SC_PHYS_PAGES is not supported." ) );

    long page_size = sysconf( _SC_PAGESIZE );
    kvsMessageWarning( page_size != -1,
                       ::GetWarningMessage( errno, "_SC_PAGESIZE is not supported." ) );

    return phys_page_size * page_size;

// Mac OS X
#elif defined ( KVS_PLATFORM_MACOSX )
#if defined ( KVS_PLATFORM_CPU_64 )
    uint64_t memory_size = 0;
    size_t   length      = sizeof( memory_size );
    int      ret         = 0;
    ret = sysctlbyname( "hw.memsize", &memory_size, &length, NULL, 0 );
    kvsMessageWarning( ret != -1, strerror( errno ) );
    return memory_size;
#else
    uint32_t memory_size = 0;
    size_t   length      = sizeof( memory_size );
    int      ret         = 0;
    ret = sysctlbyname( "hw.physmem", &memory_size, &length, NULL, 0 );
    kvsMessageWarning( ret != -1, strerror( errno ) );
    return memory_size;
#endif
#endif
}
开发者ID:digirea,项目名称:KVS,代码行数:46,代码来源:SystemInformation.cpp


示例6: os_get_total_physical_memory

/**
 * Return the size of the total physical memory.
 * \param size returns the size of the total physical memory
 * \return true for success, or false on failure
 */
bool
os_get_total_physical_memory(uint64_t *size)
{
#if defined(PIPE_OS_LINUX)
   const long phys_pages = sysconf(_SC_PHYS_PAGES);
   const long page_size = sysconf(_SC_PAGE_SIZE);

   *size = phys_pages * page_size;
   return (phys_pages > 0 && page_size > 0);
#elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD)
   size_t len = sizeof(size);
   int mib[2];

   mib[0] = CTL_HW;
#if defined(PIPE_OS_APPLE)
   mib[1] = HW_MEMSIZE;
#elif defined(PIPE_OS_NETBSD) || defined(PIPE_OS_OPENBSD)
   mib[1] = HW_PHYSMEM64;
#elif defined(PIPE_OS_FREEBSD)
   mib[1] = HW_REALMEM;
#else
#error Unsupported *BSD
#endif

   return (sysctl(mib, 2, &size, &len, NULL, 0) == 0);
#elif defined(PIPE_OS_HAIKU)
   system_info info;
   status_t ret;

   ret = get_system_info(&info);
   *size = info.max_pages * B_PAGE_SIZE;
   return (ret == B_OK);
#elif defined(PIPE_OS_WINDOWS)
   MEMORYSTATUSEX status;
   BOOL ret;

   status.dwLength = sizeof(status);
   ret = GlobalMemoryStatusEx(&status);
   *size = status.ullTotalPhys;
   return (ret == TRUE);
#else
#error unexpected platform in os_sysinfo.c
   return false;
#endif
}
开发者ID:kallisti5,项目名称:mesa_intel,代码行数:50,代码来源:os_misc.c


示例7: l_freeMemory

static int l_freeMemory (lua_State *L) {
#if defined(_WIN32) && (defined(__CYGWIN__) || defined(__CYGWIN32__))
  MEMORYSTATUS status;
  status.dwLength = sizeof(status);
  GlobalMemoryStatus( &status );
  lua_pushnumber(L, status.dwAvailPhys);
#elif defined(_WIN32)
  MEMORYSTATUSEX status;
  status.dwLength = sizeof(status);
  GlobalMemoryStatusEx( &status );
  lua_pushnumber(L, (size_t)status.ullAvailPhys);
#else
  long pages = sysconf(_SC_AVPHYS_PAGES);
  long page_size = sysconf(_SC_PAGE_SIZE);
  lua_pushnumber(L, pages * page_size);
#endif
  return 1;
}
开发者ID:StarChasers,项目名称:LuPI2,代码行数:18,代码来源:lnative.c


示例8: platform_guess_reasonable_maxmemory

/* Make a guess for a reasonable amount of memory for the hashtable
 * @return number of kilo-bytes to be used
 */
unsigned long platform_guess_reasonable_maxmemory(void)
{
    unsigned long const one_giga = 1024*1024;
    unsigned long result = one_giga;

    MEMORYSTATUSEX memstatEx;
    memstatEx.dwLength = sizeof memstatEx;
    if (GlobalMemoryStatusEx(&memstatEx))
    {
        unsigned long const one_kilo = 1024;
        unsigned long long const available_kilos = memstatEx.ullAvailPhys/one_kilo;
        /* we are really erring on the safe side here :-) */
        if (available_kilos<=ULONG_MAX)
            result = (unsigned long)available_kilos;
    }

    return result;
}
开发者ID:thomas-maeder,项目名称:popeye,代码行数:21,代码来源:maxmem.c


示例9: GetRamInfo

RamInfo GetRamInfo()
{
	static Cache<RamInfo> Value;

	return Value.Get([]() 
	{
		MEMORYSTATUSEX MemInfo;
		MemInfo.dwLength = sizeof(MEMORYSTATUSEX);
		GlobalMemoryStatusEx(&MemInfo);

		RamInfo Info;
		Info.TotalPhysicalRam = MemInfo.ullTotalPhys;
		Info.TotalVirtualRam = MemInfo.ullTotalVirtual;
		Info.TotalPageRam = MemInfo.ullTotalPageFile;

		return Info;
	});
}
开发者ID:TLeonardUK,项目名称:Ludo,代码行数:18,代码来源:Environment.cpp


示例10: meminfo_totalram

/**
 * @file
 * @brief 
 * Total Ram
 *
 * @details
 * This function looks up the total ram in bytes.
 *
 * @param totalram
 * Output, passed by reference.  On successful return, the value
 * is set to the total ram (in bytes) available on the system.
 *
 * @return
 * The return value indicates the status of the function.
 */
int meminfo_totalram(memsize_t *totalram)
{
  int ret = MEMINFO_OK;
  *totalram = 0L;
  
  
#if OS_LINUX
  struct sysinfo info;
  int test = sysinfo(&info);
  chkret(test, FAILURE);
  
  *totalram = (memsize_t) info.totalram * info.mem_unit;
#elif OS_MAC
  int test = sysctl_val("hw.memsize", totalram);
  chkret(test, FAILURE);
#elif OS_WINDOWS
  MEMORYSTATUSEX status;
  status.dwLength = sizeof(status);
  
  int test = GlobalMemoryStatusEx(&status);
  winchkret(test, FAILURE);
  
  *totalram = (memsize_t) status.ullTotalPhys;
#elif OS_FREEBSD
  int test = sysctl_val("hw.physmem", totalram);
  chkret(test, FAILURE);
#elif OS_NIX
  memsize_t npages, pagesize;
  
  npages = sysconf(_SC_PHYS_PAGES);
  if (npages == FAILURE)
    return FAILURE;
  
  pagesize = sysconf(_SC_PAGESIZE);
  if (pagesize == FAILURE)
    return FAILURE;
  
  *totalram = (memsize_t) npages * pagesize;
#else
  ret = PLATFORM_ERROR;
#endif
  
  return ret;
}
开发者ID:cran,项目名称:memuse,代码行数:59,代码来源:raminfo.c


示例11: swap_free_func

/* FIXME: should be using PERFORMANCE_INFORMATION.CommitTotal */
g_val_t
swap_free_func ( void )
{
   MEMORYSTATUSEX stat;
   DWORDLONG size;
   g_val_t val;

   stat.dwLength = sizeof(stat);

   if ( GlobalMemoryStatusEx (&stat)) {
      size = stat.ullAvailPageFile;
      /* get the value in kB */
      val.f =  size / 1024;
   } else {
      val.f = 0;
   }

   return val;
}
开发者ID:colama,项目名称:colama-3rdparty-tools,代码行数:20,代码来源:metrics.c


示例12: GetAvailableMemory

//*****************************************************************************
INT64 GetAvailableMemory()
{
#ifdef _WIN32
    // Size of available memory in bytes, with an additional
    // 200Mb subtracted to take into account heap fragmentation,
    // and a 100Mb buffer for smaller allocations that may happen in
    // between checks.
    MEMORYSTATUSEX  statex;
    statex.dwLength = sizeof (statex);
    INT64 maxAvailable = 0L;
    if(GlobalMemoryStatusEx (&statex)) {
        maxAvailable = min(statex.ullAvailPhys + statex.ullAvailPageFile, statex.ullAvailVirtual);
        maxAvailable = (maxAvailable > 300000000L) ? maxAvailable - 300000000L : 0L;
    }
    return maxAvailable;
#else // LINUX
    throw new MgNotImplementedException(L"GetAvailableMemory", __LINE__, __WFILE__, NULL, L"", NULL);
#endif
}
开发者ID:asir6,项目名称:Colt,代码行数:20,代码来源:CoordSysUtil.cpp


示例13: meminfo_gettext

static int meminfo_gettext(int tag, char *buf)
{
	MEMORYSTATUSEX memory;
	memory.dwLength = sizeof(memory);
	GlobalMemoryStatusEx(&memory);
	return ksprintf(buf,
		"MemTotal:  %13llu kB\n"
		"MemFree:   %13llu kB\n"
		"HighTotal: %13llu kB\n"
		"HighFree:  %13llu kB\n"
		"LowTotal:  %13llu kB\n"
		"LowFree:   %13llu kB\n"
		"SwapTotal: %13llu kB\n"
		"SwapFree:  %13llu kB\n",
		memory.ullTotalPhys / 1024ULL, memory.ullAvailPhys / 1024ULL,
		0ULL, 0ULL,
		memory.ullTotalPhys / 1024ULL, memory.ullAvailPhys / 1024ULL,
		memory.ullTotalPageFile / 1024ULL, memory.ullAvailPageFile / 1024ULL);
}
开发者ID:AnXi-TieGuanYin-Tea,项目名称:flinux,代码行数:19,代码来源:procfs.c


示例14: dep_initialize

/**
 * @brief
 *      Called from machine independent code to do any machine
 *      dependent initialization.
 *
 * @return      Void
 *
 */
void
dep_initialize()
{
	MEMORYSTATUSEX		mse;
	SYSTEM_INFO		si;

	mse.dwLength = sizeof(MEMORYSTATUSEX);
	GlobalMemoryStatusEx(&mse);
	pmem_size = mse.ullTotalPhys / 1024;

	GetSystemInfo(&si);
	num_acpus = num_oscpus = num_pcpus = si.dwNumberOfProcessors;
	page_size = si.dwPageSize;

	if (!init_profile("\\System\\Processor Queue Length", &mom_prof)) {
		log_err(-1, "dep_initialize", "init_profile failed!");
		return;
	}
}
开发者ID:A9-William,项目名称:pbspro,代码行数:27,代码来源:mom_mach.c


示例15: ustring_GlobalMemoryStatus

int ustring_GlobalMemoryStatus(lua_State *L)
{
	MEMORYSTATUSEX ms;
	ms.dwLength = sizeof(ms);

	if(0 == GlobalMemoryStatusEx(&ms))
		return SysErrorReturn(L);

	lua_createtable(L, 0, 8);
	PutNumToTable(L, "MemoryLoad",           ms.dwMemoryLoad);
	PutNumToTable(L, "TotalPhys",            CAST(double, ms.ullTotalPhys));
	PutNumToTable(L, "AvailPhys",            CAST(double, ms.ullAvailPhys));
	PutNumToTable(L, "TotalPageFile",        CAST(double, ms.ullTotalPageFile));
	PutNumToTable(L, "AvailPageFile",        CAST(double, ms.ullAvailPageFile));
	PutNumToTable(L, "TotalVirtual",         CAST(double, ms.ullTotalVirtual));
	PutNumToTable(L, "AvailVirtual",         CAST(double, ms.ullAvailVirtual));
	PutNumToTable(L, "AvailExtendedVirtual", CAST(double, ms.ullAvailExtendedVirtual));
	return 1;
}
开发者ID:FarGroup,项目名称:FarManager,代码行数:19,代码来源:ustring.c


示例16: QueryFreePhysicalMemory

HRESULT QueryFreePhysicalMemory( __int64 * pFreeMegaBytes )
{
    // http://msdn.microsoft.com/en-us/library/aa366589(VS.85).aspx
    // return an indication of how much free memory is available (in mb)

    HRESULT			hr = E_FAIL;
    MEMORYSTATUSEX	MemoryStatus;

    ZeroMemory( &MemoryStatus, sizeof(MEMORYSTATUSEX) );
    *pFreeMegaBytes = 0;

    if( GlobalMemoryStatusEx(&MemoryStatus) )
    {
        *pFreeMegaBytes = ((MemoryStatus.ullAvailPhys / 1024) / 1024);
        hr				= S_OK;
    }

    return hr;
}
开发者ID:gwgrisk,项目名称:msc-hull-snowglobe,代码行数:19,代码来源:MemoryUtils.cpp


示例17: mem_total_func

g_val_t
mem_total_func ( void )
{
   MEMORYSTATUSEX stat;
   DWORDLONG size;
   g_val_t val;

   stat.dwLength = sizeof(stat);

   if ( GlobalMemoryStatusEx (&stat)) {
      size = stat.ullTotalPhys;
      /* get the value in kB */ 
      val.f =  size / 1024;
   } else {
      val.f = 0;
   }

   return val;
}
开发者ID:colama,项目名称:colama-3rdparty-tools,代码行数:19,代码来源:metrics.c


示例18: getmem

static unsigned int getmem(void)
{
	unsigned int mem = 0;
#ifdef KONOHA_ON_MACOSX
	int mem_sels[2] = { CTL_HW, HW_PHYSMEM };
	size_t length = sizeof(int);
	sysctl(mem_sels, 2, &mem, &length, NULL, 0);
	mem = (unsigned int) mem / ONE_MB;
#elif defined(KONOHA_ON_WINDOWS)
	MEMORYSTATUSEX stat;
	GlobalMemoryStatusEx(&stat);
	mem = (unsigned int) stat.ullTotalPhys / ONE_MB;
#elif defined(KONOHA_ON_LINUX)
	mem = (unsigned int) getpagesize() * sysconf (_SC_PHYS_PAGES) / ONE_MB;
#else
	TODO();
#endif
	return mem;
}
开发者ID:imasahiro,项目名称:konoha-jit-deprecated,代码行数:19,代码来源:security.c


示例19: readMemoryCounters

/**
 * Populates the host_memory structure using data retrieved using
 * GlobalMemoryStatusEx function and the Memory performance counter
 * object.
 * Returns FALSE if call to GlobalMemoryStatusEx produces an error, TRUE otherwise.
 * Note that the Windows use of memory and classification of use does
 * not map cleanly to Linux terms.
 * We are using Windows available memory for mem_free. Available memory
 * includes standby memory (memory removed from a process's working set 
 * - its physical memory - on route to disk, but is still available to be recalled)
 * and free and zero page list bytes. Windows Resource Monitor reports free memory 
 * as free page list bytes.
 * Memory\\Cache Bytes is used for mem_cached since this really does appear to be
 * the Linux equivalent of cache (file system cache).
 * Windows Resource Monitor reports cached as Standby+Modified this is not the
 * equivalent of Linux file system cache.
 * Windows also does not seem to report swapping (all memory associated with a process
 * swapped in/out of memory). Memory\\Pages Input/sec and Memory\\Pages Output/sec
 * are used for page_in and page_out.
 */
BOOL readMemoryCounters(SFLHost_mem_counters *mem) 
{
	MEMORYSTATUSEX memStat;
	memStat.dwLength = sizeof(memStat);
	if (GlobalMemoryStatusEx(&memStat) == 0){
		myLog(LOG_ERR,"GlobalMemoryStatusEx failed: %d\n",GetLastError());
		return FALSE;
	}
	mem->mem_total = memStat.ullTotalPhys;
	mem->mem_free = memStat.ullAvailPhys;
	mem->swap_total = memStat.ullTotalPageFile;
	mem->swap_free = memStat.ullAvailPageFile;
	PDH_HQUERY query;
	if (PdhOpenQuery(NULL, 0, &query) == ERROR_SUCCESS) {
		PDH_HCOUNTER cache, pageIn, pageOut;
		if (addCounterToQuery(MEM_COUNTER_OBJECT, NULL, MEM_COUNTER_CACHE, &query, &cache) == ERROR_SUCCESS &&
			addCounterToQuery(MEM_COUNTER_OBJECT, NULL, MEM_COUNTER_PAGE_IN, &query, &pageIn) == ERROR_SUCCESS &&
			addCounterToQuery(MEM_COUNTER_OBJECT, NULL, MEM_COUNTER_PAGE_OUT, &query, &pageOut) == ERROR_SUCCESS &&
			PdhCollectQueryData(query) == ERROR_SUCCESS) {
			mem->mem_cached= getRawCounterValue(&cache);
			mem->page_in = (uint32_t)getRawCounterValue(&pageIn);
			mem->page_out = (uint32_t)getRawCounterValue(&pageOut);
		}
		PdhCloseQuery(query);
	}

	//There are no obvious Windows equivalents
    mem->mem_shared = UNKNOWN_COUNTER_64;
	mem->mem_buffers = UNKNOWN_COUNTER_64;
	//using the definition that swapping is when all the memory associated with a
	//process is moved in/out of RAM
	mem->swap_in = UNKNOWN_COUNTER;
	mem->swap_out = UNKNOWN_COUNTER;
	myLog(LOG_INFO,
		"readMemoryCounters:\n\ttotal: \t\t%I64d\n\tfree: \t\t%I64d\n"
		"\tcached: \t%I64d\n\tpage_in: \t%d\n\tpage_out: \t%d\n"
		"\tswap_total: \t%I64d\n\tswap_free: \t%I64d\n",
		mem->mem_total,mem->mem_free,
		mem->mem_cached,mem->page_in,mem->page_out,
		mem->swap_total, mem->swap_free);
	return TRUE;
}
开发者ID:svn2github,项目名称:host-sflow,代码行数:62,代码来源:readMemoryCounters.c


示例20: m_startup_clock

    Environment::Environment() : m_startup_clock(std::chrono::system_clock::now())
    {
        // detect the compiler
        std::ostringstream compiler;
#ifdef _MSC_VER
        compiler << "MSC - " << _MSC_VER;
#elif defined(__clang__)
        compiler << "Clang - " << __clang_major__ << '.' << __clang_minor__ << '.'
                 << __clang_patchlevel__;
#elif defined(__GNUC__)
        compiler << "GCC - " << __GNUC__ << '.' << __GNUC_MINOR__ << '.' << __GNUC_PATCHLEVEL__;
#else
        compiler << "unknown";
#endif
        m_compiler = compiler.str();

#if WIN32_WMI
        WMIServices wmi;

        // query system info
        auto proc_prop = wmi.get_properties(
          L"SELECT * FROM Win32_Processor", {L"Caption", L"Name", L"L2CacheSize"});
        m_system_info = proc_prop[0] + " - " + proc_prop[1] + " - L2Cache(KiB) " + proc_prop[2];
        MEMORYSTATUSEX memory_status;
        ZeroMemory(&memory_status, sizeof(memory_status));
        memory_status.dwLength = sizeof(memory_status);
        if (GlobalMemoryStatusEx(&memory_status))
        {
            std::ostringstream memory_size;
            memory_size << ", System memory: " << memory_status.ullTotalPhys / (1024. * 1024.)
                        << " GiB";
            m_system_info += memory_size.str();
        }

        // query os name
        auto os_prop = wmi.get_properties(L"SELECT * FROM Win32_OperatingSystem", {L"Caption"});
        m_operating_sytem = os_prop[0];
#else
        m_operating_sytem = "unknown";
        m_system_info     = "unknown";
#endif
    }
开发者ID:giucamp,项目名称:density,代码行数:42,代码来源:environment.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GlobalRNG函数代码示例发布时间:2022-05-30
下一篇:
C++ GlobalMemoryStatus函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap