how to get OS parameters

I am wanting to write a debug tool and I am stuck on one thing:

How do I obtain the OS parameters (ie platform, version number etc)?

Any help/advice appreciated.
What, you mean using autoconf?
On which OS ?
On Windows, just use standard Win32 apis
Hello,

Here is the sample application for getting OS parameters.

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
char *pathvar;

pathvar = getenv("PATH");
printf("pathvar=%s",pathvar);

return 0;
}

Same way pass other Environment Variables as char* to getenv( char* ) and u will get OS parameters for windows.

-
Regards
Kunal Nandi
I'd like to point out that that method is unreliable. If you're going to get info specific to Windows, you might as well use GetSystemInfo().
Last edited on
Actually, it is a debug tool we would like to give out to customers that, ultimately, could run off most OS and would report the user's OS specifics in the log file. Windows/mac, maybe unix...

s
if you are looking for something completely cross platform, Java may be a good idea. I've never really been a fan of it, but it has it's benefits for things like this.

see: http://www.roseindia.net/java/beginners/OSInformation.shtml <-- #'s 20-22, it's how to get OS info in java.

java isn't too hard to learn, inheritance is a bit different, and there are lots of unnecessary 'features' built into the language, but it's good for cross platform purposes.
ok, so assuming I just go with a windows version... what is the best method? I haven't found a very good description of GetSystemInfo online or C++ ref books yet.... any recommendations/advice?

S
Everything you want to do is OS-dependant. You'll need to write code specific to each OS you wish to handle.

Your compiler can help you out in that respect. See
http://predef.sourceforge.net/preos.html

Good luck!
http://predef.sourceforge.net/preos.html

Oh, god. I think I need to change my underwear. For more than one reason.
Topic archived. No new replies allowed.