In C# how do I get the list of local computer names like what one gets viewing the Network in windows explorer

前端 未结 4 1063
甜味超标
甜味超标 2020-12-01 22:12

There are a lot of questions about getting the name and IP addresses of the local machine and several about getting IP addresses of other machines on the LAN (not all answer

4条回答
  •  一个人的身影
    2020-12-01 22:46

    You can try using the System.DirectoryServices namespace.

    var root = new DirectoryEntry("WinNT:");
    foreach (var dom in root.Children) {
        foreach (var entry in dom.Children) {
            if (entry.Name != "Schema") {
                Console.WriteLine(entry.Name);
            }
        }
    }
    

提交回复
热议问题