|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Detecting redirection of standard portsI 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? How about use the Console class?
Show quote "PIEBALD" <PIEB***@discussions.microsoft.com> wrote in message news:CB5746A3-0CD1-4377-B7CE-8B7930F16ED1@microsoft.com... > 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. |
|||||||||||||||||||||||