7

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.

4
  • 5
    In short, there is no platform independent way for this. There may be similarities between Linux, BSD and OSX, but still different enough for you to have to write specific code. Then there's Windows, which is going to be very different from the POSIX systems. And if you're targeting phones/tablets it might not even be possible to get all hardware. Commented Aug 20, 2013 at 6:17
  • @Joachim Pileborg Thanks for your comment. I have updated the question. Commented Aug 20, 2013 at 6:24
  • Also, you might want to be more specific, what information do you exactly want? Vendor Names, technical specifications, operational status, ...? Commented Aug 20, 2013 at 6:51
  • github.com/lfreist/hwinfo is currently in development and aims to provide a platform independent solution. Commented Sep 7, 2022 at 5:29

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Dmidecode reports information about your system's hardware as described in your system BIOS according to the SMBIOS/DMI standard (see a sample output). This information typically includes system manufacturer, model name, serial number, BIOS version, asset tag as well as a lot of other details of varying level of interest and reliability depending on the manufacturer. This will often include usage status for the CPU sockets, expansion slots (e.g. AGP, PCI, ISA) and memory module slots, and the list of I/O ports (e.g. serial, parallel, USB).

There is a windows port of the utility as well.

Comments

0

You may take a look to the component named "solid" in KDE sources. KDE is base on Qt and I think you could reuse that out-of-the box on Linux systems, and maybe on other platforms too.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.