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

C++ GlobalMemoryStatus函数代码示例

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

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



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

示例1: GlobalMemoryStatus

void CCppLanguageTester::test_cpp_alloc_physical_memory()
{
    MEMORYSTATUS startMemoryStatus = {0}; 
    MEMORYSTATUS afterNewMemoryStatus = {0};
    MEMORYSTATUS afterAccessMemoryStatus = {0};

    GlobalMemoryStatus(&startMemoryStatus);
    
    //申请分配10M的内存空间
    const int nAllocSize = 10 * 1024 * 1024;
    BYTE *pBuff = new BYTE[ nAllocSize ];
    GlobalMemoryStatus(&afterNewMemoryStatus);

    ZeroMemory(pBuff, nAllocSize);
    GlobalMemoryStatus(&afterAccessMemoryStatus);

    delete [] pBuff;

    FTLTRACE(TEXT("Memory Status: Start -> AfterNew -> AfterAccess\n")), 
    FTLTRACE(TEXT("  AvailPhys: %fM -> %fM -> %fM\n"), 
        (float)startMemoryStatus.dwAvailPhys/1024/1024,
        (float)afterNewMemoryStatus.dwAvailPhys/1024/1024,
        (float)afterAccessMemoryStatus.dwAvailPhys/1024/1024);
    FTLTRACE(TEXT("  AvailVirtual: %fM -> %fM -> %fM\n"), 
        (float)startMemoryStatus.dwAvailVirtual/1024/1024,
        (float)afterNewMemoryStatus.dwAvailVirtual/1024/1024,
        (float)afterAccessMemoryStatus.dwAvailVirtual/1024/1024);

    //调用new以后内存即会分配
    CPPUNIT_ASSERT(startMemoryStatus.dwAvailPhys - afterNewMemoryStatus.dwAvailPhys >= nAllocSize);
    
}
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:32,代码来源:CppLanguageTester.cpp


示例2: modmem_memory_total

static int modmem_memory_total( INSTANCE * my, int * params )
{
#ifdef WIN32
    MEMORYSTATUS mem ;
    GlobalMemoryStatus( &mem ) ;
    return mem.dwTotalPhys ;

#elif defined(TARGET_BEOS)
    system_info info;
    get_system_info( &info );
    return  B_PAGE_SIZE * ( info.max_pages );

#elif !defined(TARGET_MAC) && !defined(TARGET_WII)
    /* Linux and other Unix (?) */
    struct sysinfo meminf;
    int fv;

    if ( sysinfo( &meminf ) == -1 ) return -1;

    if ( !( fv = kernel_version_type() ) ) return -1;

    if ( fv == 1 )
        return meminf.totalram * meminf.mem_unit;
    else
        return meminf.totalram;

    return -1;

#else
    return 0; //TODO

#endif
}
开发者ID:gromv,项目名称:bennugd-old,代码行数:33,代码来源:mod_mem.c


示例3: get_random_info

static void get_random_info(unsigned char seed[16])
{
#if defined(_XBOX)
   AssertFatal(false, "get_random_info not implemented on Xbox360");
#else
    MD5_CTX c;
    struct {
        MEMORYSTATUS m;
        SYSTEM_INFO s;
        FILETIME t;
        LARGE_INTEGER pc;
        DWORD tc;
        DWORD l;
        TCHAR hostname[MAX_COMPUTERNAME_LENGTH + 1];

    } r;
    
    MD5Init(&c);    /* memory usage stats */
    GlobalMemoryStatus(&r.m);    /* random system stats */
    GetSystemInfo(&r.s);    /* 100ns resolution (nominally) time of day */
    GetSystemTimeAsFileTime(&r.t);    /* high resolution performance counter */
    QueryPerformanceCounter(&r.pc);    /* milliseconds since last boot */
    r.tc = GetTickCount();
    r.l = MAX_COMPUTERNAME_LENGTH + 1;

    GetComputerName(r.hostname, &r.l );
    MD5Update(&c, (unsigned char *) &r, sizeof(r));
    MD5Final(seed, &c);
#endif
}
开发者ID:campadrenalin,项目名称:terminal-overload,代码行数:30,代码来源:uuid.cpp


示例4: UpdateSystemInfoP

bool UpdateSystemInfoP( FvSystemInfo &kSI )
{
	if ( s_pfImportedGetSystemTimes )
	{
		FILETIME kIdleFileTime, kKernelFileTime, kUserFileTime;
		s_pfImportedGetSystemTimes( &kIdleFileTime, &kKernelFileTime, &kUserFileTime );

		FvUInt64 uiIdleTime = *(FvUInt64*)&kIdleFileTime;
		FvUInt64 uiKernelTime = *(FvUInt64*)&kKernelFileTime;
		FvUInt64 uiUserTime = *(FvUInt64*)&kUserFileTime;

		//gCurMaxCPU = (uiKernelTime + uiKserTime) / gCPUCount;
		//td.curCPU = gCurMaxCPU - uiIdleTime / gCPUCount;
	}

	MEMORYSTATUS kMem;
	GlobalMemoryStatus( &kMem );
	kSI.m_kMem.max.update(kMem.dwTotalPhys);
	kSI.m_kMem.val.update(kMem.dwAvailPhys);

	MIB_IPSTATS kIPStats;
	GetIpStatistics( &kIPStats );
	kSI.m_kPackTotOut.update(kIPStats.dwOutRequests);
	kSI.m_kPackDropOut.update(kIPStats.dwOutDiscards);
	kSI.m_kPackTotIn.update(kIPStats.dwInReceives);
	kSI.m_kPackDropIn.update(kIPStats.dwInDiscards);

	return true;
}
开发者ID:Kiddinglife,项目名称:geco-game-engine,代码行数:29,代码来源:FvWindowsMachineGuard.cpp


示例5: sizeof

void ofApp::checkMemory() {

    // Check  Memory

    MEMORYSTATUS memInfo;
    memInfo.dwLength = sizeof(MEMORYSTATUS);
    GlobalMemoryStatus(&memInfo);

    // Virtual Memory
    DWORDLONG totalVirtualMem = memInfo.dwTotalVirtual;
    DWORDLONG totalVirtualMemMB = totalVirtualMem / DIV;
    DWORDLONG virtualMemUsed = memInfo.dwTotalVirtual - memInfo.dwAvailVirtual;
    DWORDLONG virtualMemUsedMB = virtualMemUsed / DIV;
    cout << "Total Virtual Memory Is " << totalVirtualMemMB << " MB (" << (totalVirtualMemMB / 1000) / 1000 << " GB)." << endl;
    cout << "We Are Using " << virtualMemUsedMB  << " MB (" << (virtualMemUsedMB / 1000) / 1000 << " GB) Of That Amount. " << endl;

    // Physical Memory
    DWORDLONG totalPhysMem = memInfo.dwTotalPhys;
    DWORDLONG totalPhysMemMB = totalPhysMem / DIV;
    DWORDLONG physMemUsed = memInfo.dwTotalPhys - memInfo.dwAvailPhys;
    DWORDLONG physMemUsedMB = physMemUsed / DIV;
    cout << "Total Physical Memory Is " << totalPhysMemMB << " MB (" << (totalPhysMemMB / 1000) / 1000 << " GB)." << endl;
    cout << "We Are Using " << physMemUsedMB  << " MB (" << (physMemUsedMB / 1000) / 1000 << " GB) Of That Amount. " << endl;


}
开发者ID:JesseScott,项目名称:TheArtBox,代码行数:26,代码来源:ofApp.cpp


示例6: noise_regular

/*
 * This function is called on a timer, and it will monitor
 * frequently changing quantities such as the state of physical and
 * virtual memory, the state of the process's message queue, which
 * window is in the foreground, which owns the clipboard, etc.
 */
void noise_regular(void)
{
    HWND w;
    DWORD z;
    POINT pt;
    MEMORYSTATUS memstat;
    FILETIME times[4];

    w = GetForegroundWindow();
    random_add_noise(&w, sizeof(w));
    w = GetCapture();
    random_add_noise(&w, sizeof(w));
    w = GetClipboardOwner();
    random_add_noise(&w, sizeof(w));
    z = GetQueueStatus(QS_ALLEVENTS);
    random_add_noise(&z, sizeof(z));

    GetCursorPos(&pt);
    random_add_noise(&pt, sizeof(pt));

    GlobalMemoryStatus(&memstat);
    random_add_noise(&memstat, sizeof(memstat));

    GetThreadTimes(GetCurrentThread(), times, times + 1, times + 2,
		   times + 3);
    random_add_noise(&times, sizeof(times));
    GetProcessTimes(GetCurrentProcess(), times, times + 1, times + 2,
		    times + 3);
    random_add_noise(&times, sizeof(times));
}
开发者ID:rdebath,项目名称:sgt,代码行数:36,代码来源:noise.c


示例7: GlobalMemoryStatus

void _MEMInfo::_UpdateMI( )
{

#ifdef WIN32
	MEMORYSTATUS	MS;
	GlobalMemoryStatus( &MS );

	m_MI.nTotalMem	= MS.dwTotalPhys / 1024;
	m_MI.nFreeMem	= MS.dwAvailPhys / 1024;
#else

	char* szfile = ftostr( "/proc/meminfo" );
	char* szfind = NULL;

	if( szfile )
	{
		szfind = strstr( szfile, "MemTotal" );

		if( szfind )
			sscanf( szfind, "MemTotal:\t%u kB", 
			&m_MI.nTotalMem );


		szfind = strstr( szfile, "MemFree" );
		
		if( szfind )
			sscanf( szfind, "MemFree:\t%u kB", 
			&m_MI.nFreeMem );
	}
	
#endif
	
}
开发者ID:viticm,项目名称:pap2,代码行数:33,代码来源:mem.cpp


示例8: get_random_info

void get_random_info(unsigned char seed[16])
{
	MD5_CTX c;
	typedef struct {
		MEMORYSTATUS m;
		SYSTEM_INFO s;
		FILETIME t;
		LARGE_INTEGER pc;
		DWORD tc;
		DWORD l;
		char hostname[MAX_COMPUTERNAME_LENGTH + 1];
	} randomness;
	randomness r;

	/* Initialize memory area so that valgrind does not complain */
	memset(&r, 0, sizeof r);
	/* memory usage stats */
	GlobalMemoryStatus( &r.m );
	/* random system stats */
	GetSystemInfo( &r.s );
	/* 100ns resolution (nominally) time of day */
	GetSystemTimeAsFileTime( &r.t );
	/* high resolution performance counter */
	QueryPerformanceCounter( &r.pc );
	/* milliseconds since last boot */
	r.tc = GetTickCount();
	r.l = MAX_COMPUTERNAME_LENGTH + 1;
	GetComputerName( r.hostname, &r.l );
	/* MD5 it */
	MD5Init(&c);
	MD5Update(&c, (unsigned char *)(&r), sizeof r);
	MD5Final(seed, &c);
};
开发者ID:benjaminopy5bo,项目名称:pupnp-code,代码行数:33,代码来源:sysdep.c


示例9: guessReasonableMaxmemory

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

  /* GlobalMemoryStatusEx() has only been available since Windows 2000
   */
#if defined(_WIN32_WINNT) && _WIN32_WINNT>=_WIN32_WINNT_WIN2K

  MEMORYSTATUSEX memstatEx;
  memstatEx.dwLength = sizeof memstatEx;
  if (GlobalMemoryStatusEx(&memstatEx))
  {
    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;
  }

#else

  MEMORYSTATUS memstat;
  GlobalMemoryStatus(&memstat);
  result = memstat.dwAvailPhys/one_kilo;

#endif

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


示例10: LockMut

bool VirtualMemoryManager::EnsureFreeMemory(size_t size)
{
	if(!inited)
		return false;

	LockMut(vmemMutex);

	MEMORYSTATUS ms;
	GlobalMemoryStatus(&ms);

	while(ms.dwAvailPhys < size)
	{
		if(LOG && logging)
			LOG->Trace("Freeing memory: need %i, have %i", size, ms.dwAvailPhys);

		if(!DecommitLRU())
		{
			if(LOG)
				LOG->Trace("VMem error: No pages left to free while reserving memory");
			return false;
		}
	}

	return true;
}
开发者ID:BitMax,项目名称:openitg,代码行数:25,代码来源:VirtualMemory.cpp


示例11: Sys_InitMemory

void Sys_InitMemory(void)
{
	int i;

	i = COM_CheckParm("-heapsize");
	if (i && i < com_argc - 1)
		host_parms.memsize = Q_atoi(com_argv[i + 1]) * 1024;

	if (host_parms.memsize < MINIMUM_WIN_MEMORY)
	{
#ifdef _WIN32
		MEMORYSTATUS lpBuffer;
		lpBuffer.dwLength = sizeof(MEMORYSTATUS);
		GlobalMemoryStatus(&lpBuffer);

		if (lpBuffer.dwTotalPhys)
		{
			if (lpBuffer.dwTotalPhys < FIFTEEN_MB)
				Sys_Error("%s: Available memory less than 15MB!!! %i", __func__, host_parms.memsize);

			host_parms.memsize = (int)(lpBuffer.dwTotalPhys >> 1);
			if (host_parms.memsize < MINIMUM_WIN_MEMORY)
				host_parms.memsize = MINIMUM_WIN_MEMORY;
		}
		else
开发者ID:theAsmodai,项目名称:rehlds,代码行数:25,代码来源:sys_dll2.cpp


示例12: defined

bool COSOperator::getSystemMemory(irr::u32* Total, irr::u32* Avail)
{
#if defined(_IRR_WINDOWS_API_)
	MEMORYSTATUS MemoryStatus;
	MemoryStatus.dwLength = sizeof(MEMORYSTATUS);

	// cannot fail
	GlobalMemoryStatus(&MemoryStatus);

	if (Total)
		*Total = (irr::u32)(MemoryStatus.dwTotalPhys>>10);
	if (Avail)
		*Avail = (irr::u32)(MemoryStatus.dwAvailPhys>>10);
	
	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
	return true;

#elif defined(_IRR_POSIX_API_) // || defined(MACOSX)
        long ps = sysconf(_SC_PAGESIZE);
        long pp = sysconf(_SC_PHYS_PAGES);
        long ap = sysconf(_SC_AVPHYS_PAGES);
 
	if ((ps==-1)||(pp==-1)||(ap==-1))
		return false;

	if (Total)
		*Total = ((ps*(long long)pp)>>10);
	if (Avail)
		*Avail = ((ps*(long long)ap)>>10);
	return true;
#endif
	// TODO: implement for OSX 
	return false;
}
开发者ID:flaithbheartaigh,项目名称:mirrlicht,代码行数:34,代码来源:COSOperator.cpp


示例13: Dlg_OnTimer

void Dlg_OnTimer(HWND hwnd, UINT id) {

   // Initialize the structure length before calling GlobalMemoryStatus.
   MEMORYSTATUS ms = { sizeof(ms) };
   GlobalMemoryStatus(&ms);

   TCHAR szData[512] = { 0 };
   StringCchPrintf(szData, _countof(szData), 
      TEXT("%d\n%d\n%I64d\n%I64d\n%I64d\n%I64d\n%I64d"),
      ms.dwMemoryLoad, ms.dwTotalPhys, 
      (__int64) ms.dwAvailPhys,     (__int64) ms.dwTotalPageFile, 
      (__int64) ms.dwAvailPageFile, (__int64) ms.dwTotalVirtual, 
      (__int64) ms.dwAvailVirtual);

   SetDlgItemText(hwnd, IDC_DATA, szData);

   // Get the current process working set and private bytes.
   PROCESS_MEMORY_COUNTERS_EX pmc = { sizeof(PROCESS_MEMORY_COUNTERS_EX) };
   GetProcessMemoryInfo(GetCurrentProcess(), (PPROCESS_MEMORY_COUNTERS)&pmc, sizeof(pmc));
   StringCchPrintf(szData, _countof(szData), 
      TEXT("%I64d K\n%I64d K"),
      (__int64) pmc.WorkingSetSize / 1024,
      (__int64) pmc.PrivateUsage / 1024);
   SetDlgItemText(hwnd, IDC_PROCESSDATA, szData);
}
开发者ID:Jeanhwea,项目名称:WindowsViaCPP,代码行数:25,代码来源:VMStat.cpp


示例14: updateMemoryStatus

void updateMemoryStatus()
{
	//メモリの使用状況を更新する
	static Uint32 m_uMemoryUse    = 1;
	static Uint32 m_uMemoryMaxUse = 1;
	static Uint32 m_uMemoryTotal  = 0;

    MEMORYSTATUS memory;

    memory.dwLength = sizeof( MEMORYSTATUS );
    GlobalMemoryStatus( &memory );

	if( m_uMemoryTotal == 0 )
	{
		//ゲームで使用可能なメモリ量を計測
		m_uMemoryTotal = memory.dwAvailPhys;
		m_uMemoryTotal = memory.dwAvailVirtual;
	}

	//現在ゲームが使用しているメモリ量
	m_uMemoryUse   = m_uMemoryTotal - memory.dwAvailPhys;
	m_uMemoryUse   = m_uMemoryTotal - memory.dwAvailVirtual;

	//最大風速
	if( m_uMemoryUse > m_uMemoryMaxUse ) m_uMemoryMaxUse = m_uMemoryUse;

	CGameGirl::GetInstance()->ReportMemoryStatus( m_uMemoryUse , m_uMemoryTotal , m_uMemoryMaxUse );
}
开发者ID:programmerMOT,项目名称:gxlib,代码行数:28,代码来源:Win32cmn.cpp


示例15: GlobalMemoryStatus

/*
 * int sysinfo(struct sysinfo *info)
 */
void SysCalls::sys_sysinfo(CONTEXT& ctx)
{
	linux::sysinfo si;
	
	MEMORYSTATUS ms;
	GlobalMemoryStatus(&ms);

	memset(&si, 0, sizeof(si));
	si.uptime = GetTickCount()/1000;
	si.loads[0] = 0; //1, 5, and 15 minute load averages
	si.loads[1] = 0;
	si.loads[2] = 0;
	si.totalram = ms.dwAvailPhys;
	si.freeram  = ms.dwTotalPhys;
	si.sharedram = 0;/* Amount of shared memory */
	si.bufferram = 0; /* Memory used by buffers */
	si.totalswap = ms.dwTotalPageFile;
	si.freeswap  = ms.dwAvailPageFile;
	si.procs = g_pKernelTable->m_Processes.size();
	si.totalhigh = 0; /* Total high memory size */
	si.freehigh = 0;  /* Available high memory size */
	si.mem_unit = 4096; //same as page size???

	P->WriteMemory((ADDR)ctx.Ebx, sizeof(si), &si);
	ctx.Eax = 0;
}
开发者ID:killvxk,项目名称:keow,代码行数:29,代码来源:sys_sys.cpp


示例16: DumpSystemInformation

void DumpSystemInformation(HANDLE hLogFile, TCHAR* lpModuleName)
{
	//system user name
	DWORD nUserNameSize = 120;
	TCHAR szTemp[120] = {0};
	if (!GetUserName(szTemp, &nUserNameSize))
		strcpy_s(szTemp, 120, "UnKnow");

	WriteLogFile(hLogFile, "%s run by %s.\r\n", lpModuleName, szTemp);

	//system version
	TCHAR szWinVer[50] = {0};
	TCHAR szMajorMinorBuild[50] = {0};
	int nWinVer;
	GetWinVer(szWinVer, &nWinVer, szMajorMinorBuild);
	WriteLogFile(hLogFile, "Operating system version:%s(%s).\r\n", szWinVer, szMajorMinorBuild);

	//process state
	SYSTEM_INFO sysinfo;
	GetSystemInfo(&sysinfo);
	WriteLogFile(hLogFile, "%d process, type %d.\r\n", sysinfo.dwNumberOfProcessors, sysinfo.dwProcessorType);

	//memory state
	MEMORYSTATUS meminfo;
	GlobalMemoryStatus(&meminfo);
	WriteLogFile(hLogFile, _T("%d%% memory in use.\r\n"), meminfo.dwMemoryLoad);
	WriteLogFile(hLogFile, _T("%d MBytes physical memory.\r\n"), (meminfo.dwTotalPhys+ONEM-1)/ONEM);
	WriteLogFile(hLogFile, _T("%d MBytes physical memory free.\r\n"), (meminfo.dwAvailPhys+ONEM-1)/ONEM);
	WriteLogFile(hLogFile, _T("%d MBytes paging file.\r\n"), (meminfo.dwTotalPageFile+ONEM-1)/ONEM);
	WriteLogFile(hLogFile, _T("%d MBytes paging file free.\r\n"), (meminfo.dwAvailPageFile+ONEM-1)/ONEM);
	WriteLogFile(hLogFile, _T("%d MBytes user address space.\r\n"), (meminfo.dwTotalVirtual+ONEM-1)/ONEM);
	WriteLogFile(hLogFile, _T("%d MBytes user address space free.\r\n"), (meminfo.dwAvailVirtual+ONEM-1)/ONEM);
}
开发者ID:Harrison0984,项目名称:WinCrashReport,代码行数:33,代码来源:ExceptionHandler.cpp


示例17: GlobalMemoryStatus

void plDispatchLog::LogStatusBarChange(const char* name, const char* action)
{
    fLog->AddLineF("----- Status bar '%s' %s -----", name, action);

#ifdef HS_BUILD_FOR_WIN32
    MEMORYSTATUS ms;
    GlobalMemoryStatus(&ms);

    MEMORY_BASIC_INFORMATION mbi;
    memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));

    // Note: this will return shared mem too on Win9x.  There's a way to catch that, but it's too slow -Colin
    uint32_t processMemUsed = 0;
    void* curAddress = 0;
    while (VirtualQuery(curAddress, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) == sizeof(MEMORY_BASIC_INFORMATION))
    {
        if (mbi.State == MEM_COMMIT && mbi.Type == MEM_PRIVATE)
            processMemUsed += mbi.RegionSize;
        curAddress = ((BYTE*)mbi.BaseAddress) + mbi.RegionSize;
    }
    
    #define ToMB(mem) float(mem) / (1024.f*1024.f)
    fLog->AddLineF("# Mem stats");
    fLog->AddLineF("#   Physical: %.1f MB used %.1f MB free", ToMB(ms.dwTotalPhys-ms.dwAvailPhys), ToMB(ms.dwAvailPhys));
    fLog->AddLineF("#   Virtual:  %.1f MB used %.1f MB free", ToMB(ms.dwTotalVirtual-ms.dwAvailVirtual), ToMB(ms.dwAvailVirtual));
    fLog->AddLineF("#   Pagefile: %.1f MB used %.1f MB free", ToMB(ms.dwTotalPageFile-ms.dwAvailPageFile), ToMB(ms.dwAvailPageFile));
    fLog->AddLineF("#   Process:  %.1f MB used", ToMB(processMemUsed));
#endif // HS_BUILD_FOR_WIN32
}
开发者ID:branan,项目名称:Plasma,代码行数:29,代码来源:pfDispatchLog.cpp


示例18: sizeof

CString CBot::SysInfo()
{	CString sSysInfo;
#ifdef WIN32
	int total=GetTickCount()/1000;
	MEMORYSTATUS memstat; OSVERSIONINFO verinfo;
	char szBuffer[MAX_COMPUTERNAME_LENGTH + 1];
	DWORD dwNameSize = MAX_COMPUTERNAME_LENGTH + 1;
	char *szCompname;
	TCHAR szUserName[21];
	DWORD dwUserSize = sizeof(szUserName);

	GlobalMemoryStatus(&memstat); verinfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); GetVersionEx(&verinfo); char *os; char os2[140];
	if(verinfo.dwMajorVersion==4 && verinfo.dwMinorVersion==0)
	{	if(verinfo.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)			os="95";
		if(verinfo.dwPlatformId==VER_PLATFORM_WIN32_NT)					os="NT"; }
	else if(verinfo.dwMajorVersion==4 && verinfo.dwMinorVersion==10)	os="98";
	else if(verinfo.dwMajorVersion==4 && verinfo.dwMinorVersion==90)	os="ME";
	else if(verinfo.dwMajorVersion==5 && verinfo.dwMinorVersion==0)		os="2000";
	else if(verinfo.dwMajorVersion==5 && verinfo.dwMinorVersion==1)		os="XP";
	else if(verinfo.dwMajorVersion==5 && verinfo.dwMinorVersion==2)		os="2003";
	else																os="???";

	if(verinfo.dwPlatformId==VER_PLATFORM_WIN32_NT && verinfo.szCSDVersion[0]!='\0')
	{	sprintf(os2, "%s [%s]", os, verinfo.szCSDVersion); os=os2; }
	GetComputerName(szBuffer, &dwNameSize);
	szCompname = szBuffer;
	GetUserName(szUserName, &dwUserSize);

	// *** PhaTTy <MOD> Changed ram: to ##MB/##MB , added box: , added user: </MOD>

	sSysInfo.Format("cpu: %dMHz ram: %dMB/%dMB os: %s (%d.%d, build %d) uptime: %dd %dh %dm box: %s user: %s freespace: %s",
	cpuspeed(), memstat.dwAvailPhys/1046528, memstat.dwTotalPhys/1046528, os, verinfo.dwMajorVersion, verinfo.dwMinorVersion, verinfo.dwBuildNumber, total/86400, (total%86400)/3600, ((total%86400)%3600)/60, szCompname, szUserName , GetFreeDiskSpace().CStr());


#else
	FILE *fp=fopen("/proc/uptime", "r");
	float f1, f2;
	
	if(!fp) return CString("Error: Can't open /proc/uptime!");

	if(fscanf(fp, "%f %f", &f1, &f2)<2) return CString("Error: Invalid or changed /proc/uptime format!");

	fclose(fp);
	
	int days, hours, minutes;
	days=((abs((int)f1)/60)/60)/24;
	hours=((abs((int)f1)/60)/60)%24;
	minutes=(abs((int)f1)/60)%60;

	int iDistro=GetDistro(); char *szVersion; char *szKVersion;
	bool bGotVer=GetVersion(&szVersion, iDistro);
	bool bGotKVer=GetKVersion(&szKVersion, iDistro);
	
	if(!bGotVer) szVersion="Unknown\n"; if(!bGotKVer) szKVersion="Unknown\n";
	
	sSysInfo.Format("cpu: %dMHz. os: %s. kernel: %s. uptime: %dd %dh %dm", cpuspeed(), szVersion, szKVersion, days, hours, minutes);

	if(bGotVer) free(szVersion); if(bGotKVer) free(szKVersion);
#endif
	return sSysInfo; }
开发者ID:A-Massarella,项目名称:Botnet,代码行数:60,代码来源:bot.cpp


示例19: rand_init

/**
 * random init
 * @return void
 */
void rand_init()
{
	struct
	{
#ifndef _WIN32
		struct timeval nowt; /* time */
		char rnd[32]; /* /dev/urandom */
#else
		MEMORYSTATUS mstat; /* memory status */
		struct _timeb nowt; /* time */
#endif
	} rdat;

	arc4_init();

	/* Grab OS specific "random" data */
#ifndef _WIN32
	/* unix/bsd: time */
	gettimeofday(&rdat.nowt, NULL);
	/* unix/bsd: /dev/urandom */
	int fd = open("/dev/urandom", O_RDONLY);
	if (fd)
	{
		read(fd, &rdat.rnd, sizeof(rdat.rnd));
		close(fd);
	}
#else
	/* win32: time */
	_ftime(&rdat.nowt);
	/* win32: memory status */
	GlobalMemoryStatus(&rdat.mstat);
#endif

	arc4_addrandom(&rdat, sizeof(rdat));
}
开发者ID:xxgrunge,项目名称:anope196,代码行数:39,代码来源:misc.cpp


示例20: gfx_ctx_d3d_update_title

static void gfx_ctx_d3d_update_title(void *data)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   char buf[128], buffer_fps[128];
   bool fps_draw = g_settings.fps_show;

   if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buffer_fps : NULL, sizeof(buffer_fps)))
   {
#ifndef _XBOX
      SetWindowText(d3d->hWnd, buf);
#endif
   }

   if (fps_draw)
   {
#ifdef _XBOX
      char mem[128];
      MEMORYSTATUS stat;
      GlobalMemoryStatus(&stat);
      snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
      strlcat(buffer_fps, mem, sizeof(buffer_fps));
#endif
      msg_queue_push(g_extern.msg_queue, buffer_fps, 1, 1);
   }

#ifndef _XBOX
   g_extern.frame_count++;
#endif
}
开发者ID:TroggleMonkey,项目名称:RetroArch,代码行数:29,代码来源:d3d_ctx.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ GlobalMemoryStatusEx函数代码示例发布时间:2022-05-30
下一篇:
C++ GlobalLock16函数代码示例发布时间: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