使用 WMI 和 C# 检测机器是在线还是离线

detect if machine is online or offline using WMI and C#(使用 WMI 和 C# 检测机器是在线还是离线)
本文介绍了使用 WMI 和 C# 检测机器是在线还是离线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的是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# 检测机器是在线还是离线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)