问题描述
我用的是vs2008,winxp,局域网内有Win2003服务器.
I use vs2008, winxp, in LAN network with Win2003 servers.
我想在winxp中安装一个应用程序来检测win2003机器是在线还是离线,启动时是否离线.
I want a application installed in winxp for detect if win2003 machines is online or offline , and if offline when boot it.
我有这些参考资料,还有更多参考资料、代码示例和最佳实践吗??
I have this references, any more references, code samples and best practices ??
http://danielvl.blogspot.com/2004/06/how-to-ping-in-c-using.html
http://snipplr.com/view/2157/ping-using-wmi-pingstatus/
http://dotnoted.wordpress.com/2005/01/15/the-popular-c-ping-utility/
http://www.visualbasicscript.com/Ping-WMI-amp-NonWMI-Versions-Functions-amp-Simple-Connectivity-Monitor-m42535.aspx
推荐答案
我会选择.NET System.Net.NetworkInformation.Ping
,因为它非常灵活,你有可能异步执行它,我发现它比 WMI 更直观(我已经使用了这两种方法,并且仅当我需要从远程机器获取更多信息而不仅仅是 ping 时才使用 WMI).但这只是个人意见.
I would go for the .NET System.Net.NetworkInformation.Ping
, because it is quite flexible, you have the possibility of doing it asynchronously and I find it more intuitive than WMI (I have used both and use WMI only if I need to get more info from the remote machine than just the ping). But this is just a personal opinion.
这篇关于使用 WMI 和 C# 检测机器是在线还是离线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!