How do I read system information in C++?

后端 未结 4 1320
谎友^
谎友^ 2021-02-04 16:29

I\'m trying to get information like OS version, hard disk space, disk space available, and installed RAM on a Linux system in C++. I know I can use system() to run

4条回答
  •  太阳男子
    2021-02-04 17:09

    There is nothing in the C++ Standard library for these purposes. The library you could use is libhal, which abstracts the view of programs to the hardware, collecting various informations from /proc, /sys and others. HAL, scroll down, there seems to be an unofficial C++ binding available too (haven't tested it though, while libhal works also fine for C++ programs). Use the command lshal to display all device informations available to HAL.

提交回复
热议问题