detect if machine is online or offline using WMI and 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# 检测机器是在线还是离线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 WMI 和 C# 检测机器是在线还是离线


- 使用 rss + c# 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01