You can get them from the registry.
If installed from the network control panel:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\SearchList
If set by Group Policy:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient\SearchList
Use the registry class for reading , the same class can be used, but for this you will need administrator permissions.
C # using management classes and WMI:
ManagementObjectSearcher q= new ManagementObjectSearcher("SELECT ServiceName,DNSDomainSuffixSearchOrder FROM Win32_NetworkAdapterConfiguration");// WHERE DNSDomainSuffixSearchOrder IS NOT NULL"); var qc= q.Get(); foreach (ManagementObject mo in qc) { if ( mo.Properties["DNSDomainSuffixSearchOrder"] != null) { var s = mo.Properties["DNSDomainSuffixSearchOrder"]; if (s.Value != null) { Console.WriteLine(mo["ServiceName"]); string[] sfxNames = s.Value as string[]; foreach (string sx in sfxNames) { Console.WriteLine(sx); } } } }
source share