I want to be able to run "netstat -n" and grab the output somehow so I can then write it out to another file.
How can I do this in C++ on Windows CE
Thankyou
Chris
I want to be able to run "netstat -n" and grab the output somehow so I can then write it out to another file.
How can I do this in C++ on Windows CE
Thankyou
Chris
http://msdn.microsoft.com/en-us/library/ms682499%28VS.85%29.aspx
But not pretty sure it'll work under CE
You must call CreateProcess and override the process's output handle:
STARTUPINFO aInfo;
...
aINfo.hStdOutput = myHandle;
CreateProcess(..., &aInfo, ...);
I solved this by essentially calling netstat from the cmd prompt, piping the output to a file, and then using it from there. I believe Kerido's answer to be right but this is how I got it working.
This code then launches cmd.exe and telling it to run netstat -n. Note that the /c is required else cmd.exe will not launch the code
int retVal = CreateProcessW(L"cmd.exe", L"/c netstat -n > \"/netstatoutput.txt\"", NULL, NULL, NULL, CREATE_NEW_CONSOLE, NULL, NULL, NULL, NULL);