code: def _Reg2Py(data, size, data_type):
    
    if data_type == winreg.REG_DWORD:
      if size == 0:
        return 0
      # DWORD is an unsigned 32-bit integer, see:
      # https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/262627d8-3418-4627-9218-4ffe110850b2
      return ctypes.cast(data, ctypes.POINTER(ctypes.c_uint32)).contents.value
    elif data_type == winreg.REG_SZ or data_type == winreg.REG_EXPAND_SZ:
      return ctypes.wstring_at(data, size // 2).rstrip(u"\x00")
    elif data_type == winreg.REG_MULTI_SZ:
      return ctypes.wstring_at(data, size // 2).rstrip(u"\x00").split(u"\x00")
    else:
      if size == 0:
        return None
      return ctypes.string_at(data, size)
docs: Converts a Windows Registry value to the corresponding Python data type.