Is it possible to write a Ping class in C# that will run within Windows 8 Metro environment?(是否可以用 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 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以用 C# 编写一个将在 Windows 8 Metro 环境中运行的 Ping 类?
基础教程推荐
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- WPF 模态进度窗口 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
