本文介绍了Windows CE 上的 isatty的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Windows CE 上是否有与 isatty()
等效的东西?换句话说,有没有办法在代码中检测 stdin/stdout/stderr 是否已被重定向?
Is there an equivalent to isatty()
on windows CE? In other words, is there a way to detect in code if stdin/stdout/stderr has been redirected?
推荐答案
你可以调用 GetStdIoPath(它在 coredll.dll 中 - 它没有在 MSDN 中记录,我不确定它是否在任何 SDK 头文件中,但你总是可以手动将其声明为 extern,链接器会找到它).
You could call GetStdIoPath (it's in coredll.dll - it's not documented in MSDN and I'm not sure if it's in any SDK headers, but you can always manually declare it as extern and the linker will find it).
这是我的 C# 版本 - 如有必要,您可以轻松地将其移植回 C:
Here's my C# version - you can easily port it back to C if necessary:
[DllImport("coredll.dll", SetLastError = true)]
public static extern int GetStdioPath(StdIoStream id, StringBuilder pwszBuf, int lpdwLength);
public enum StdIoStream
{
Input = 0,
Output = 1,
ErrorOutput = 2
}
这篇关于Windows CE 上的 isatty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!