C++ - Using system() for Windows commands
c++, windows, windows-xp
Solution
Most of the calls you'd make have Windows API calls you can use directly. Ideally, you'd just call the appropriate Windows API call instead of launching a process, writing to a file, then parsing the file.
That being said, on Windows, `CreateProcess` will launch a process and provide you a lot more control than a call to `system`. This includes using `STARTUPINFO` to provide your own `HANDLE` for the process standard output stream, which means you can directly read from the process without writing to a file.
Problem
I'm new to C++, and I've read and heard that using system calls is bad practice. So what if you need to use system() to run a Windows command like `ipconfig` or `netstat`. Is it still evil or is that considered an acceptable use of system()? I'm writing a program to collect a variety of information about the system and I use system() many times and pipe the output into text files for review.