Detecting redirection of standard ports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I often write console programs that need to detect when stdin and stdout are
redirected.

I found out how to detect this for stdin by using API calls GetStdHandle()
and PeekConsoleInput() (from a Dr. GUI article).

But I still need to detect such for stdout, is there a way?

And shouldn't this be a property of the standard streams?
 
Well, of course I'm using the Console class, but it has no built-in detection
for redirection. It allows one to redirect, but won't tell you whether or not
it's _already_ redirected.
 
Back
Top