Detect hardware information in a C ++ application?

I want to define hardware information such as CPU, RAM, Hard Disk, GPU, etc. My application is in C ++, but built on Qt. How to get this information? Thanks.

EDIT: There seems to be no platform independent way for this. So please, can you list the code for well-known OSs such as Windows, OSX and Ubuntu?

EDIT: I'm talking about basic information such as processor speed, amount of available RAM, hard drive speed, GPU speed and memory.

+4
source share
3 answers

MS provides some functions for programmatically searching for this information (including Windows.h):

BOOL WINAPI GetPhysicallyInstalledSystemMemory( _Out_ PULONGLONG TotalMemoryInKilobytes ); 

Retrieves RAM information, 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 free space on the disk volume, see the 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 processor, the number of processors in the system, page size and other such information, see this MS website .

+2
source

You can use dmidecode to get a variety of information about your equipment. Since the software is open source (GPL), you can look at the source code to find out how to do it:

Dmidecode reports information about your system hardware, as described in the BIOS of your system, in accordance with the SMBIOS / DMI standard (see sample output). This information usually includes the manufacturer of the system, model name, serial number, BIOS version, asset tag, as well as many other details of various levels of interest and reliability depending on the manufacturer. This often includes usage status for processor sockets, expansion slots (e.g., AGP, PCI, ISA) and memory module slots, as well as a list of I / O ports (e.g., serial, parallel, USB).

There is also a Windows port .

0
source

You can take a look at a component called "solid" in KDE sources. KDE is based on Qt, and I think you could reuse this out of the box on Linux systems and possibly other platforms.

0
source

Source: https://habr.com/ru/post/1497930/


All Articles