"Protoman" <Pr**********@gmail.com> writes:
For example, how would I beable to write a simple program that
determines the processor the program's executing on? Use WinXP's
enviroment variable PROCESSOR_ARCHITECTURE?
PROCESSOR_ARCHITECTURE is not set to anything on my system, (which
isn't windows), but here is a program that reads the value of
the environment variable PATH that usually exist both in unix
and windows environments. I'm sure you are able to modify it to
suit your needs.
#include <stdlib.h> /* getenv */
#include <stdio.h> /* printf */
int main(void)
{
const char* key = "PATH";
const char* val = getenv(key);
if (val != NULL) {
printf("%s=%s\n", key, val);
}
else {
printf("%s not set\n", key);
}
return 0;
}
Note that getenv returns a char pointer to the value of the
environment variable. You should not modify it's content, and
you must not release it's memory. If you wan't to do anything
with it you should copy it to a buffer that you have control
over.
/Niklas Norrthon