是否可以用 C# 编写一个将在 Windows 8 Metro 环境中运行的 Ping 类? [英] Is it possible to write a Ping class in C# that will run within Windows 8 Metro environment?

查看:15
本文介绍了是否可以用 C# 编写一个将在 Windows 8 Metro 环境中运行的 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.

这篇关于是否可以用 C# 编写一个将在 Windows 8 Metro 环境中运行的 Ping 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆