def RegistryResolve():
    nameservers=[]
    x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
    try:
        y= _winreg.OpenKey(x,
         r"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters")
    except EnvironmentError: # so it isn't NT/2000/XP
        # windows ME, perhaps?
        try: # for Windows ME
            y= _winreg.OpenKey(x,
                 r"SYSTEM\CurrentControlSet\Services\VxD\MSTCP")
            nameserver,dummytype=_winreg.QueryValueEx(y,'NameServer')
            if nameserver and not (nameserver in nameservers):
                nameservers.extend(stringdisplay(nameserver))
        except EnvironmentError:
            pass
        return nameservers # no idea
    try:
        nameserver = _winreg.QueryValueEx(y, "DhcpNameServer")[0].split()
    except:
        nameserver = _winreg.QueryValueEx(y, "NameServer")[0].split()
    if nameserver:
        nameservers=nameserver
    nameserver = _winreg.QueryValueEx(y,"NameServer")[0]
    _winreg.CloseKey(y)
    try: # for win2000
        y= _winreg.OpenKey(x,
         r"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DNSRegisteredAdapters")
        for i in range(1000):
            try:
                n=_winreg.EnumKey(y,i)
                z=_winreg.OpenKey(y,n)
                dnscount,dnscounttype=_winreg.QueryValueEx(z,
                                            'DNSServerAddressCount')
                dnsvalues,dnsvaluestype=_winreg.QueryValueEx(z,
                                            'DNSServerAddresses')
                nameservers.extend(binipdisplay(dnsvalues))
                _winreg.CloseKey(z)
            except EnvironmentError:
                break
        _winreg.CloseKey(y)
    except EnvironmentError:
        pass
#
    try: # for whistler
        y= _winreg.OpenKey(x,
         r"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces")
        for i in range(1000):
            try:
                n=_winreg.EnumKey(y,i)
                z=_winreg.OpenKey(y,n)
                try:
                    nameserver,dummytype=_winreg.QueryValueEx(z,'NameServer')
                    if nameserver and not (nameserver in nameservers):
                        nameservers.extend(stringdisplay(nameserver))
                except EnvironmentError:
                    pass
                _winreg.CloseKey(z)
            except EnvironmentError:
                break
        _winreg.CloseKey(y)
    except EnvironmentError:
        #print "Key Interfaces not found, just do nothing"
        pass
#
    _winreg.CloseKey(x)
    return nameservers
dataset/ETHPy150Open Flolagale/mailin/python/DNS/win32dns.py/RegistryResolve/original