是否可以用 C# 编写一个将在 Windows 8 Metro 环境中运行的 Ping 类?将在、可以用、环境、Windows

由网友(会傲)分享简介:由于 Windows 8 上的 Metro 环境缺少大部分 .NET 框架类库或包含大幅缩减的版本,是否可以从 Metro 风格应用程序执行ping"?支持 Sockets,所以我想有希望,但我不知道从哪里开始,因为每个C# Ping"示例都使用 System.Net.NetworkInformation.Ping,这...

由于 Windows 8 上的 Metro 环境缺少大部分 .NET 框架类库或包含大幅缩减的版本,是否可以从 Metro 风格应用程序执行ping"?支持 Sockets,所以我想有希望,但我不知道从哪里开始,因为每个C# Ping"示例都使用 System.Net.NetworkInformation.Ping,这在 WinRT 中不可用.

Since the Metro environment on Windows 8 lacks most of the .NET framework class libraries or contains a substancially pared down version, is it possible to execute a "ping" from a Metro style application? There is support for Sockets, so I guess there is hope, but I don't know where to start, since every "C# Ping" example uses System.Net.NetworkInformation.Ping and that is not available in WinRT.

我还查看了 Mono 的源代码,他们的 ping 实现会启动 ping.exe 并从命令行的标准输出窗口返回结果.

I also looked into the source code for Mono, and their ping implementation fires up ping.exe and returns the result from the standard output window of the command line.

推荐答案

不,很遗憾没有.WinRT 不支持 ICMP:IcmpCreateFile 和相关的 Win32 API 仅在桌面"API 分区中可用.ICMP 可以使用原始套接字实现,但由于 WinRT 不支持这些(并且通常需要提升,无论如何),您也无法使用此选项.

No, unfortunately not. ICMP is not supported in WinRT: IcmpCreateFile and related Win32 APIs are only available in the "desktop" API partition. ICMP can be implemented using raw sockets but since these are not supported in WinRT (and usually require elevation, anyway), this option is also not available to you.

我自己作为 Windows 应用商店网络扫描工具的开发者(http://lanscan.rcook.org/),我很想能够做到这一点.

As the developer of a Windows Store network scanning tool myself (http://lanscan.rcook.org/), I'd love to be able to do this.

阅读全文

相关推荐

最新文章