我试图找到与我的工作站不同的工作站的友好操作系统名称。这是我使用时发生的:
var name = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
select x.GetPropertyValue("Caption")).FirstOrDefault();
它返回我工作站的OS名称。您能建议我找到一种更好的方法吗?
提前谢谢!
答案 0 :(得分:1)
您可以使用System.DirectoryServices在目录“ WinNT”上进行搜索,您可以在此处了解更多信息:
示例解决方案-将名称添加到列表
// create list to add the names to
var pcnames = new List<string>();
// establish the domains in the local network
var directory = new DirectoryEntry("WinNT:");
// iterate through the children
foreach (DirectoryEntry workstation in directory.Children)
{
pcnames.Add(workstation.Name)
}