获取计算机名称从我的邻居 [英] Getting computer names from my network places
问题描述
我不知道是否有一种方式来获得,在使用C#我的网络位置显示在所有的计算机名称。
您想使用NetServerEnum()API。我不相信这是在基本.NET库这样的托管包装,但我可以用快速谷歌搜索发现这一点:的http://www.$c$cproject.com/Articles/16113/Retreiving-a-list-of-network-computer-names-using
的注意的:我没有测试或彻底审查了$ C $的CProject code,但它应该是足够的起点,你所需要的,如果有任何问题。 p>
编辑:不要使用的DirectoryServices除非你的肯定域环境的。该的System.DirectoryServices类是一个ADSI包装,dosent工作没有一个Active Directory对查询。 NetServerEnum()适用于工作组和域,但这么想的保证了最可靠的数据(不是所有的机器可能会出现)。它依赖于计算机浏览器服务。
最好的解决办法可能是一个包装两种可能性和合并结果的类:/
I was wondering if there is a way to get all the computer names that show up in my network places using C#.
You will want to use the NetServerEnum() API. I dont believe there is a managed wrapper for this in the base .NET libraries but I was able to find this with a quick google search: http://www.codeproject.com/Articles/16113/Retreiving-a-list-of-network-computer-names-using
NOTE: I haven't tested or thoroughly reviewed the codeproject code but it should be enough of a starting point for what you need if there are any issues.
EDIT: Do not use DirectoryServices unless your sure of a domain environment. The System.DirectoryServices class is an ADSI wrapper that dosent work without an Active Directory to query against. NetServerEnum() works on workgroups and domains but dosen't guarantee the most reliable data (not all machines may show up). It relies on the Computer Browser service.
The best solution would probably be a class that wraps both possibilities and merges the results :/
这篇关于获取计算机名称从我的邻居的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!