Skip to content

Commit be5d976

Browse files
committed
Update document
1 parent e3b84c9 commit be5d976

File tree

2 files changed

+118
-1
lines changed

2 files changed

+118
-1
lines changed

Doc/library/winreg.rst

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,42 @@ This module offers the following functions:
420420
.. audit-event:: winreg.QueryValue key,sub_key,value_name winreg.QueryValueEx
421421

422422

423+
.. function:: GetValue(key, sub_key, value_name, flags=RRF_RT_ANY)
424+
425+
Retrieves the type and data for a specified registry value without requiring
426+
the key to be opened first.
427+
428+
*key* is an already open key, or one of the predefined
429+
:ref:`HKEY_* constants <hkey-constants>`.
430+
431+
*sub_key* is a string that holds the name of the subkey with which the value
432+
is associated. If this parameter is ``None`` or empty, the value will be read
433+
from the key specified by *key*.
434+
435+
*value_name* is a string indicating the value to query, or ``None`` for the
436+
default value of the subkey.
437+
438+
*flags* is an integer that specifies the restrictions on the value type to
439+
be queried (see :ref:`RRF_* constants <rrf-constants>`). Default is
440+
``RRF_RT_ANY``.
441+
442+
The result is a tuple of 2 items:
443+
444+
+-------+-----------------------------------------+
445+
| Index | Meaning |
446+
+=======+=========================================+
447+
| ``0`` | The value of the registry item. |
448+
+-------+-----------------------------------------+
449+
| ``1`` | An integer giving the registry type for |
450+
| | this value (see table in docs for |
451+
| | :meth:`SetValueEx`) |
452+
+-------+-----------------------------------------+
453+
454+
.. audit-event:: winreg.GetValue key,sub_key,value_name,flags winreg.GetValue
455+
456+
.. versionadded:: next
457+
458+
423459
.. function:: SaveKey(key, file_name)
424460

425461
Saves the specified key, and all its subkeys to the specified file.
@@ -766,6 +802,83 @@ For more information, see `Registry Value Types
766802
You should pass a :class:`str` or :const:`None` in Python for this type.
767803

768804

805+
.. _rrf-constants:
806+
807+
RRF_* Constants
808+
+++++++++++++++
809+
810+
Registry value retrieval flags used with :func:`GetValue`.
811+
812+
.. data:: RRF_RT_ANY
813+
814+
No type restriction. All registry value types will be returned.
815+
816+
817+
.. data:: RRF_RT_DWORD
818+
819+
Restrict query to 32-bit values.
820+
821+
822+
.. data:: RRF_RT_QWORD
823+
824+
Restrict query to 64-bit values.
825+
826+
827+
.. data:: RRF_RT_REG_BINARY
828+
829+
Restrict query to binary data (REG_BINARY).
830+
831+
832+
.. data:: RRF_RT_REG_DWORD
833+
834+
Restrict query to REG_DWORD values.
835+
836+
837+
.. data:: RRF_RT_REG_QWORD
838+
839+
Restrict query to REG_QWORD values.
840+
841+
842+
.. data:: RRF_RT_REG_EXPAND_SZ
843+
844+
Restrict query to expandable strings (REG_EXPAND_SZ).
845+
846+
847+
.. data:: RRF_RT_REG_MULTI_SZ
848+
849+
Restrict query to multi-strings (REG_MULTI_SZ).
850+
851+
852+
.. data:: RRF_RT_REG_NONE
853+
854+
Restrict query to null values (REG_NONE).
855+
856+
857+
.. data:: RRF_RT_REG_SZ
858+
859+
Restrict query to null-terminated strings (REG_SZ).
860+
861+
862+
.. data:: RRF_NOEXPAND
863+
864+
Do not automatically expand environment variables in REG_EXPAND_SZ values.
865+
866+
867+
.. data:: RRF_ZEROONFAILURE
868+
869+
Set buffer contents to zeroes on failure.
870+
871+
872+
.. data:: RRF_SUBKEY_WOW6464KEY
873+
874+
Query the 64-bit registry view on 64-bit Windows.
875+
876+
877+
.. data:: RRF_SUBKEY_WOW6432KEY
878+
879+
Query the 32-bit registry view on 64-bit Windows.
880+
881+
769882
.. _handle-object:
770883

771884
Registry Handle Objects

PC/winreg.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ PyDoc_STRVAR(module_doc,
6868
" specified key in the registry.\n"
6969
"QueryValueEx() - Retrieves the type and data for a specified value name\n"
7070
" associated with an open registry key.\n"
71+
"GetValue() - Retrieves the type and data for a specified registry value\n"
72+
" without requiring the key to be opened first.\n"
7173
"QueryInfoKey() - Returns information about the specified key.\n"
7274
"SaveKey() - Saves the specified key, and all its subkeys a file.\n"
7375
"SetValue() - Associates a value with a specified key.\n"
@@ -2301,14 +2303,16 @@ exec_module(PyObject *m)
23012303
ADD_INT(RRF_RT_DWORD);
23022304
ADD_INT(RRF_RT_QWORD);
23032305
ADD_INT(RRF_RT_REG_BINARY);
2306+
ADD_INT(RRF_RT_REG_DWORD);
23042307
ADD_INT(RRF_RT_REG_EXPAND_SZ);
23052308
ADD_INT(RRF_RT_REG_MULTI_SZ);
23062309
ADD_INT(RRF_RT_REG_NONE);
2310+
ADD_INT(RRF_RT_REG_QWORD);
23072311
ADD_INT(RRF_RT_REG_SZ);
23082312
ADD_INT(RRF_NOEXPAND);
2313+
ADD_INT(RRF_ZEROONFAILURE);
23092314
ADD_INT(RRF_SUBKEY_WOW6464KEY);
23102315
ADD_INT(RRF_SUBKEY_WOW6432KEY);
2311-
ADD_INT(RRF_WOW64_MASK);
23122316

23132317
#undef ADD_INT
23142318
return 0;

0 commit comments

Comments
 (0)