'Extract resolver configuration from the Windows registry.'

def read_registry(self):

    lm = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
    want_scan = False
    try:
        try:
            tcp_params = _winreg.OpenKey(lm, 'SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters')
            want_scan = True
        except EnvironmentError:
            tcp_params = _winreg.OpenKey(lm, 'SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP')
        try:
            self._config_win32_fromkey(tcp_params)
        finally:
            tcp_params.Close()
        if want_scan:
            interfaces = _winreg.OpenKey(lm, 'SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces')
            try:
                i = 0
                while True:
                    try:
                        guid = _winreg.EnumKey(interfaces, i)
                        i += 1
                        key = _winreg.OpenKey(interfaces, guid)
                        if (not self._win32_is_nic_enabled(lm, guid, key)):
                            continue
                        try:
                            self._config_win32_fromkey(key)
                        finally:
                            key.Close()
                    except EnvironmentError:
                        break
            finally:
                interfaces.Close()
    finally:
        lm.Close()
