我该如何在C#中获取Windows 10机器的DNS后缀搜索列表?
例如,如果我在命令提示符中键入ipconfig
,我会看到类似以下内容:
Windows IP Configuration
Host Name . . . . . . . . . . . . : BOB
Primary Dns Suffix . . . . . . . : fred.george.com
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : fred.com
george.com
我希望能够返回一个包含'fred.com'和'george.com'的数组。我已经尝试了一些不同的方法[1],但它们使用适配器属性(这些属性为空)。
[1] https://learn.microsoft.com/en-us/dotnet/api/system.net.networkinformation.ipinterfaceproperties.dnssuffix?view=netframework-4.8