if u are working in a linux/solaris box then just do
man proc
or /proc.. its is a file-system that has all info pertaining
to the system and all the processes.
u can do sum programming on proc file-system.
(personally i wud use sum scripting language to extract the info ;-) )
iam sorry i have no idea abt windows.
Alternatively u can do a snmp walk on the system.. u can try this for remote systems also . but they must be running the snmp agent. u can get all info abt the system, its up-time , services and network info.
I am saying to get information of computer hardware configuration information, it should be software independent, ie., no matter linux/unix or windows the configuration information should be retrieved. Besides, since the portability of C language, it should be a big deal over different operation system.
I think you are saying the utility function of operation systems. No, I don't mean that. I meant a C function can retract the information.
Lemme try to give u a "not-so-funny" answer (well atleast acc. 2 me )
as far as my "limited knowledge" of C and English goes
i think you are referring to a C library function..
FYI, these are the headers for the ANSI C lib.
<assert.h> : Diagnostics
<ctype.h> : Character Class Tests
<errno.h> : Error Codes Reported by (Some) Library Functions
<float.h> : Implementation-defined Floating-Point Limits
<limits.h> : Implementation-defined Limits
<locale.h> : Locale-specific Information
<math.h> : Mathematical Functions
<setjmp.h> : Non-local Jumps
<signal.h> : Signals
<stdarg.h> : Variable Argument Lists
<stddef.h> : Definitions of General Use
<stdio.h> : Input and Output
<stdlib.h> : Utility functions
<string.h> : String functions
<time.h> : Time and Date functions
Well using any of the functions in the C library to get the info u require.. the closest i can get is to use system and then based on the OS xtract d info..
if u are looking for a "platform-independent" way to get sys. info in C, I dont think the ANSI C library supports any such feature.
i think that perl and python offers support to get sys. info
but the necessary api/library have to be there
This question always pops up at about this time of year. I assume someone sets it in a course. There are demos on how to get processor information in the freebie demo section on the installation disks for almost any language.
ANSI C cannot guaruntee to give you information such as COM ports, because ANSI C has to work for any computer, whether or not it actually has anything describable as a port. In fact it wouldn't be sensible even to put a "name of processor" function in ANSI C, because the language should be processor independant, and not all processors will provide a way to tell what they are. The methods of determining what processor you have in an IBM PC prior to pentium rely on devious tricks, because the processor ID op-code wasn't added until pentium. I'd imagine the situation is similar in other systems.
I recall long time ago, an C program(ANSI C) was using <dos.h> and some int21h(not sure the interruption number) to extract system information successfully. So I am pretty sure ANSI C can do this job successfully. The only problem is I couldn't remember how it was written. And it took me a long time to search the references.
I think someone here had experience in doing this with C.
Not that it matters since this forum isn't about ansi-c
exclusively.
I don't know anyone here who is going to pull magic
tricks with dos.h and inline assembly for you.
Also I thought you wanted this to be portable?
Not getting there with dos.h.
Take a look at the source code for hwinfo(linux),
or a project like cpu-z for windows.
Better yet take a gander at some of the opensource
alternative bios code(open bios, linux bios), for
an idea of how to query hardware and write platform
agnostic hardware accessing code.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.