• Advertisement

Archived

This topic is now archived and is closed to further replies.

How to get memory and CPU information by C/C++?

This topic is 5789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all. I''d like to know the simplest way the get the CPU and memory statistic and information by C/C++. Is it possible to do it without MFC? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Memmory-
use VOID GlobalMemoryStatus(
LPMEMORYSTATUS lpBuffer // pointer to the memory status structure
);
like this:
MEMORYSTATUS stat;
GlobalMemoryStatus(&stat);
now stat is ready, heres the structure
typedef struct _MEMORYSTATUS { // mst
DWORD dwLength; // sizeof(MEMORYSTATUS)
DWORD dwMemoryLoad; // percent of memory in use
DWORD dwTotalPhys; // bytes of physical memory
DWORD dwAvailPhys; // free physical memory bytes
DWORD dwTotalPageFile; // bytes of paging file
DWORD dwAvailPageFile; // free bytes of paging file
DWORD dwTotalVirtual; // user bytes of address space
DWORD dwAvailVirtual; // free user bytes
} MEMORYSTATUS, *LPMEMORYSTATUS;


for CPU-
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-CPUDetect&forum=cotd&id=-1
and
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-CPUID&forum=cotd&id=-1

Share this post


Link to post
Share on other sites

  • Advertisement