问题描述
在Windows 7(和Vista,我认为),你连接网络,被分配到一个位置如家庭/工作或公共。
In Windows 7 (and Vista I think), a network you're connected to is assigned to a "location" e.g. Home / Work or Public.
是否有可能以编程方式来确定当前的网络位置?
Is it possible to determine the current network location programatically?
推荐答案
使用 Windows API的code包,你能够获得网络相同的列表中的Windows显示,通过使用 NetworkListManager.GetNetworks(NetworkConnectivityLevels.All)
。
Using Windows API Code Pack, you are able to get the same list of networks that Windows shows, by using NetworkListManager.GetNetworks(NetworkConnectivityLevels.All)
.
然后,是类别
每个网络告诉不论是公共或私人(家庭/工作)命名的属性。似乎有没有办法从家和工作,虽然区别。
Then, there's a property named Category
on each network which tells whether it is public or private (home / work). There seems to be no way to distinguish from 'home' and 'work' though.
这篇关于如何确定与QUOT;网络位置和QUOT;在.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!