Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distinguishing a pipe from a file in windows

On Unix, everything is a file, so you can use file i/o functions with pipes, files, sockets, etc. But on windows, the api you use depends on the type of i/o HANDLE you have.

My question is: given a HANDLE how do you determine what the underlying type is? For example, I have a HANDLE that's either real file, or a named/anonymous pipe. I'd like to know whether PeekNamedPipe can be called on this HANDLE.

like image 808
paleozogt Avatar asked Dec 13 '25 04:12

paleozogt


1 Answers

Use GetFileType. Check for a return value of FILE_TYPE_PIPE.

http://msdn.microsoft.com/en-us/library/aa364960(VS.85).aspx


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!