Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Hardware information in C++ application? [closed]

Tags:

c++

hardware

I want to determine Hardware information like CPU, RAM, Hard Disk, GPU, etc. My application is in C++ but is built on Qt. How to get this information? Thank You.

EDIT: Looks like there is no platform independent way for this. So please can you list the code for prominent OS like Windows, OSX & Ubuntu?

EDIT: I am talking about basic information like processor speed, amount of RAM available, hard disk speed, GPU speed & memory.

like image 574
Cool_Coder Avatar asked Aug 20 '13 06:08

Cool_Coder


1 Answers

MS provides some functions to look up these informations programmatically (include Windows.h):

BOOL WINAPI GetPhysicallyInstalledSystemMemory(  _Out_  PULONGLONG TotalMemoryInKilobytes );

Retrieves informations about the RAM, see documentation.

BOOL WINAPI GetDiskFreeSpaceEx(
 _In_opt_   LPCTSTR lpDirectoryName,
 _Out_opt_  PULARGE_INTEGER lpFreeBytesAvailable,
 _Out_opt_  PULARGE_INTEGER lpTotalNumberOfBytes,
 _Out_opt_  PULARGE_INTEGER lpTotalNumberOfFreeBytes
);

Retrieves information about the amount of space that is available on a disk volume, see documentation.

SYSTEM_INFO siSysInfo; 
// Copy the hardware information to the SYSTEM_INFO structure.  
GetSystemInfo(&siSysInfo); 

Contains information about the current computer system. This includes the architecture and type of the processor, the number of processors in the system, the page size, and other such information, see this MS site.

like image 162
fiscblog Avatar answered Nov 15 '22 05:11

fiscblog