Hi,
I want to get hardware information or list in C++. As you know using system(); or exec(); is not a standard way to do that and the output is distribution dependent
In windows, we can use WMI to do that. But any API in Linux?
Thanks
Hi,
I want to get hardware information or list in C++. As you know using system(); or exec(); is not a standard way to do that and the output is distribution dependent
In windows, we can use WMI to do that. But any API in Linux?
Thanks
There is no answer yet?
If you want to really nit-pick the details, this is "kernel space" programming, ie. the API for hardware is part of the kernel API. However, the kernel is strictly C as Mr. Torvalds does not like the C++ language.
However, the kernel already exports all the data and puts it in the /proc directory. All you have to do is parse the directory structure and text files there-in, which you can do that however you like and it will be much, much simpler and easier.
Last edited by MK27; 07-19-2009 at 09:24 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Ou, thanks.
Is there any program that do the parsing of /proc and give us the details
in a good format?!
I don't know exactly what you want to do, but I don't think that you need to mess with the kernel for that. Probably you should take a look at devicekit.
As a side note, I hope that Linux and c++ will always be 2 diverging objects, because c++ is one of the most horrible piece of cr.p I've ever seen, while c is just beatiful(I'm obviously talking about those parts where the 2 differ).
I want to get hardware info like type and size of memory, name and size of hard disk, information about graphic card and so on. It's better to do that with linux API (if exists?!) in C or C++.
/proc is mostly processes but if you look thru it you will noticed the hardware is registered there too (since they are taken care of by kernal driver modules which are processes). Eg. this is the content of /proc/asound/cards for me:
You can also get much info from the "lspci" and "lsusb" commands. Read the man pages for them. I'm not sure if the /proc layout is the same and standard everywhere, but it probably is. You'll have to find out what the kernel's policy is for organizing the data.Code:0 [CS4281 ]: CS4281 - Cirrus Logic CS4281 Cirrus Logic CS4281 at 0xfdaff000, irq 17
Last edited by MK27; 07-20-2009 at 10:55 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Hi,
I found something:
and dmidecode, lshw (lshw-gtk), hwinfo. Most of them are bash files not c code or Linux API except ezix that is c code(I haven't read it's code,
maybe using system command ) but I think in linux using bash files are common !!!!
If you're searching for things like that, I guess that you could take a look at libraries like libhd(the library used by hwinfo) or libdiscover(the library used by discover). And again, even devicekit may be useful. After that, you can take a look directly at /sys and /proc.
Great, libhd is like what I want. Thansk a lot
But about discover? It is not common and it seems that it is not used a lot
However Thanks for your helps