Windows equivalent to “/dev/stdin”?

会有一股神秘感。 提交于 2019-12-30 08:14:45

问题


I have Python code talking to a C++ library which only takes filenames. I want it to read from stdin. On Unix machines I can use "/dev/stdin". I thought I could use the special "CON" device on Windows, but that's more like /dev/tty in that "echo something | my_program" does not work.

Supporting pipes under Windows isn't essential, but now I'm curious. Is there something like the filename "/dev/stdin" for that OS?


回答1:


To the best of my knowledge there is no equivalent of /dev/stdin. However, if you really needed to you could create your own named pipe (CreateNamedPipe) and pass the name to the C++ library, using a separate thread to feed the input from stdin into the named pipe.




回答2:


The equivalent pseudo files on Windows are conIN$ and conOUT$.




回答3:


I may be misinterpreting your question - you know about cin and stdin, right? If you need a real live winapi handle for ReadFile or whatever, use GetStdHandle(STD_INPUT_HANDLE)



来源:https://stackoverflow.com/questions/7395157/windows-equivalent-to-dev-stdin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!