Is it possible to write a Ping class in C# that will run within Windows 8 Metro environment?

≡放荡痞女 提交于 2019-12-29 08:40:10

问题


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.

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.


回答1:


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.

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



来源:https://stackoverflow.com/questions/10952346/is-it-possible-to-write-a-ping-class-in-c-sharp-that-will-run-within-windows-8-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!