本文介绍了如何在网络中查找工作站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试识别网络中的工作站.使用c#识别工作站的可能方法是什么.
谢谢,
Arshad
i am trying to identify workstations in network. what are the possible way to identify workstations using c#.
Thanks,
Arshad
推荐答案
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_OperatingSystem WHERE ProductType = 2");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_OperatingSystem instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("ProductType: {0}", queryObj["ProductType"]);
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
}
}
}
ProductType映射到下表:
值=含义
1 =工作站
2 =域控制器
3 =服务器
http://msdn.microsoft.com/zh-我们/library/windows/desktop/aa394239%28v=vs.85%29.aspx [ ^ ]
谢谢,
Arshad
ProductType maps to below table :
Value =Meaning
1 = Work Station
2 = Domain Controller
3 = Server
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394239%28v=vs.85%29.aspx[^]
Thanks,
Arshad
这篇关于如何在网络中查找工作站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!