What is winreg.QueryValueEx in Python?

winreg (Windows Registry API) provides functions to expose the Windows Registry API to Python. We use this module to expose a low-level interface to the registry.

QueryValueEx

We use the method QueryValueEx to access information such as the type and data components for a specified value name. It is required that the value name associated with a key must be of an open key.

Syntax

winreg.QueryValueEx(key, value_name)

Parameters and return value

key: The handle which is returned by ConnectRegistry(), including the constants in HKEY_USERS or HKEY_LOCAL_MACHINE.

value_name: This refers to the value that we want to query in our keys.

Return value

This method returns a tuple containing the relevant items. At index 0, the tuple contains the value of the specific registry item. At index 1, the tuple contains the type of the specific registry item in the form of an integer value.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved