for ex: i want to store output of system("dir");
Thanks & Regards, calvin
for ex: i want to store output of system("dir");
Thanks & Regards, calvin
You can either use redirection to a file (system( "dir > file" )), read that file and delete it or go the unnamed pipes way as in Unix - call CreatePipe() to create a pipe and attach it as the input/output stream in PROCESS_INFORMATION structure and pass that structure into CreateProcess().
Yes, look at capturing stdout from CreateProcess:
Note that dir
is a built in command under DOS. So you'll have to do something like the following system command:
cmd.exe /c dir c:\path\to\directory
rather than just calling dir
. Type cmd /?
for more information on the /c
parameter.
POSIX has a popen() function and I think that Windows has something similar called _popen().