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# 检测机器是在线还是离线
基础教程推荐
- C# 从 List<List<int>> 中删除重 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
