'Iterate over all values in this key (or optionally the specified
sub-key. If get_data is True also return the data for every value,
otherwise, just the name.'

def itervalues(self, get_data=False, sub_key=None):

    key = self.hkey
    if (sub_key is not None):
        try:
            key = RegOpenKey(key, sub_key)
        except WindowsError:
            return
    try:
        name_buf = ctypes.create_unicode_buffer(16385)
        lname_buf = DWORD(len(name_buf))
        if get_data:
            data_buf = (BYTE * 1024)()
            ldata_buf = DWORD(len(data_buf))
            vtype = DWORD(0)
        i = 0
        while True:
            lname_buf.value = len(name_buf)
            if get_data:
                ldata_buf.value = len(data_buf)
                try:
                    RegEnumValue(key, i, name_buf, ctypes.byref(lname_buf), None, ctypes.byref(vtype), data_buf, ctypes.byref(ldata_buf))
                except ValueError:
                    data_buf = (BYTE * ldata_buf.value)()
                    continue
                data = convert_registry_data(data_buf, ldata_buf.value, vtype.value)
                (yield (name_buf.value[:lname_buf.value], data))
            else:
                RegEnumValue(key, i, name_buf, ctypes.byref(lname_buf), None, None, None, None)
                (yield name_buf.value[:lname_buf.value])
            i += 1
    finally:
        if (sub_key is not None):
            RegCloseKey(key)
