How do I read system information in C++?

后端 未结 4 1324
谎友^
谎友^ 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:21

    If you don't want to use HAL as litb suggests, you can read things straight out of the /proc filesystem, provided it's there on your system. This isn't the most platform-independent way of doing things, and in many cases you'll need to do a little parsing to pick apart the files.

    I think HAL abstracts a lot of these details for you, but just know that you can read it straight from /proc if using a library isn't an option.

提交回复
热议问题