Whiteknight
06-27-2004, 05:13 PM
I'm writting a C++ program that manipulates several settings on my winXP computer, one of them being the IP address settings.
I reset all the IP address values, and then I use a system call to ping an external server. for example:
system("ping www.google.com");
now, i want to capture the errorlevel of the ping program, and use that in some decision structures later in the program (ie if the ping fails, i do one thing, and if the ping succeeds i do another).
in a batch script, I could do the following:
ping www.google.com > NUL
if ERRORLEVEL 1 goto 10
if not ERRORLEVEL 1 goto 20
but I want to do this from a C++ program.
is there a way that i can caputure the value of ERRORLEVEL from C++ (with a getenv() function perhaps?) or do i need to use more system calls?
I reset all the IP address values, and then I use a system call to ping an external server. for example:
system("ping www.google.com");
now, i want to capture the errorlevel of the ping program, and use that in some decision structures later in the program (ie if the ping fails, i do one thing, and if the ping succeeds i do another).
in a batch script, I could do the following:
ping www.google.com > NUL
if ERRORLEVEL 1 goto 10
if not ERRORLEVEL 1 goto 20
but I want to do this from a C++ program.
is there a way that i can caputure the value of ERRORLEVEL from C++ (with a getenv() function perhaps?) or do i need to use more system calls?