0

How can I simulate these calls inside a program? Like say I want to find all the active connections. So I want to use netstat -a How could I use that without having to literally having a window open?

4 Answers 4

6

Use CreateProcess, redirecting the output.

If the calling application is not a windows application there is no issue with a console window (because a console programming will, by default, inheirt its parent console).

If the calling application is a windows application, set the right options passed to CreateProcess to default the console window that will be created to hidden.

Sign up to request clarification or add additional context in comments.

Comments

1

There is system() library function you can use - I guess Windows has it as well because it is standard C function since C89.

Comments

0

You will have to use the "/B" option of 'start' command.

cmd /C start "Title" /B netstat -i

I'm assuming popping console is your main problem, and you a strategy of collecting the data.

Comments

0

Never use system() (not professional, crappy)
Use Win32 net apis .
See the source code of netstat.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.