如何获取 Windows 中所有打开的命名管道的列表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/258701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get a list of all open named pipes in Windows?
提问by Doug T.
Is there an easy way to test whether your named pipe is working correctly? I want to make sure that the data I'm sending from my app is actually being sent. Is there a quick and easy way to get a list of all the named pipes?
有没有一种简单的方法来测试您的命名管道是否正常工作?我想确保我从我的应用程序发送的数据实际上正在发送。有没有一种快速简便的方法来获取所有命名管道的列表?
回答by Rob Walker
You can view these with Process Explorerfrom sysinternals. Use the "Find -> Find Handle or DLL..." option and enter the pattern "\Device\NamedPipe\". It will show you which processes have which pipes open.
您可以使用sysinternals 的Process Explorer查看这些。使用“Find -> Find Handle or DLL...”选项并输入模式“\Device\NamedPipe\”。它将显示哪些进程打开了哪些管道。
回答by Andrew Shepherd
In the Windows Powershell console, type
在 Windows Powershell 控制台中,键入
[System.IO.Directory]::GetFiles("\.\pipe\")
如果您的操作系统版本高于 Windows 7,您还可以键入
get-childitem \.\pipe\
This returns a list of objects. If you want the name only:
这将返回一个对象列表。如果你只想要名字:
(get-childitem \.\pipe\).FullName
回答by Vincent Lidou
Try the following instead:
请尝试以下操作:
String[] listOfPipes = System.IO.Directory.GetFiles(@"\.\pipe\");
回答by Jay
Use pipelist.exefrom Sysinternals.
使用Sysinternals 的pipelist.exe。
回答by Daynew
I stumbled across a feature in Chrome that will list out all open named pipes by navigating to "file://.//pipe//"
我偶然发现了 Chrome 中的一项功能,该功能将通过导航到“file://.//pipe//”来列出所有打开的命名管道
Since I can't seem to find any reference to this and it has been very helpful to me, I thought I might share.
由于我似乎找不到任何对此的参考,而且它对我很有帮助,我想我可以分享一下。
回答by Omar Elsherif
C#:
C#:
String[] listOfPipes = System.IO.Directory.GetFiles(@"\.\pipe\");
回答by Vincent Lidou
The second pipe was interpreted by this web site when submitted... You need two backslashes at the beginning. So make sure to use System.IO.Directory.GetFiles(@"\\.\pipe\").
第二个管道在提交时由本网站解释...开头需要两个反斜杠。所以一定要使用 System.IO.Directory.GetFiles(@"\\.\pipe\")。
Note that I have seen this function call throw an 'illegal characters in path.' exception when one of the pipes on my machine had invalid characters. PipleList.exe worked ok though, so it seems like a bug in MS's .net code.
请注意,我已经看到此函数调用会抛出“路径中的非法字符”。当我机器上的一个管道有无效字符时的异常。不过,PipleList.exe 工作正常,所以它似乎是 MS 的 .net 代码中的一个错误。
回答by Constantin Konstantinidis
At CMD
prompt:
在CMD
提示时:
>ver
Microsoft Windows [Version 10.0.18362.476]
>dir \.\pipe\