0

I'm trying to execute

    which file.exe

within c++ and want to redirect the result to a string to make further processes

I've tried system and CreateProcess but this executes command and redirects the results to stdout or a file.

but how do I get this result within a local string ?

Thanks

2 Answers 2

2

Redirect to a pipe (with CreateProcess) and read your end of the pipe into a local string.

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

Comments

1

I recommend to use _popen (popen on Unix).

5 Comments

Did it start working in GUI-subsystem executables? (It was not)
Are you sure there were problems? I'm not aware of any.
See the Note starting with "If used in a Windows program" on your own link to MSDN. I'm sure there were (or are) some real problems, I just don't remember them well.
Ah, I see. So whether this is good advise or not depends on whether the OP wants to create a GUI or console application.
both were helpful. I use console app so it's easier to use _popen Thanks

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.