1818
1919#include <windows.h>
2020
21+ #define MS_WINDOWS_DESKTOP
2122#if defined(MS_WINDOWS_DESKTOP ) || defined(MS_WINDOWS_SYSTEM ) || defined(MS_WINDOWS_GAMES )
2223
2324typedef struct {
@@ -1417,8 +1418,37 @@ winreg.OpenKey -> HKEY
14171418 access: REGSAM(c_default='KEY_READ') = winreg.KEY_READ
14181419 An integer that specifies an access mask that describes the desired
14191420 security access for the key. Default is KEY_READ.
1421+
1422+ Opens the specified key.
1423+
1424+ The result is a new handle to the specified key.
1425+ If the function fails, an OSError exception is raised.
1426+ [clinic start generated code]*/
1427+
1428+ static HKEY
1429+ winreg_OpenKey_impl (PyObject * module , HKEY key , const wchar_t * sub_key ,
1430+ int reserved , REGSAM access )
1431+ /*[clinic end generated code: output=5efbad23b3ffe2e7 input=7fb70c602dd114dd]*/
1432+ {
1433+ return winreg_OpenKeyEx_impl (module , key , sub_key , reserved , access , 0 );
1434+ }
1435+
1436+ /*[clinic input]
1437+ winreg.OpenKeyEx -> HKEY
1438+
1439+ key: HKEY
1440+ An already open key, or any one of the predefined HKEY_* constants.
1441+ sub_key: Py_UNICODE(accept={str, NoneType})
1442+ A string that identifies the sub_key to open.
14201443 options: int = 0
14211444 Can be one of the REG_OPTION_* constants.
1445+ access: REGSAM(c_default='KEY_READ') = winreg.KEY_READ
1446+ An integer that specifies an access mask that describes the desired
1447+ security access for the key. Default is KEY_READ.
1448+ reserved: int = 0
1449+ A reserved integer that be should zero. If it is not zero,
1450+ it will be used as the options parameter for compatibility reasons.
1451+ Default is zero.
14221452
14231453Opens the specified key.
14241454
@@ -1427,9 +1457,9 @@ If the function fails, an OSError exception is raised.
14271457[clinic start generated code]*/
14281458
14291459static HKEY
1430- winreg_OpenKey_impl (PyObject * module , HKEY key , const wchar_t * sub_key ,
1431- int reserved , REGSAM access , int options )
1432- /*[clinic end generated code: output=1cb0239fad9672e0 input=2fff042272bfc4f6 ]*/
1460+ winreg_OpenKeyEx_impl (PyObject * module , HKEY key , const wchar_t * sub_key ,
1461+ int options , REGSAM access , int reserved )
1462+ /*[clinic end generated code: output=db8d3dc70876a046 input=d997970b48ac2e30 ]*/
14331463{
14341464 HKEY retKey ;
14351465 long rc ;
@@ -1439,8 +1469,13 @@ winreg_OpenKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
14391469 (Py_ssize_t )access ) < 0 ) {
14401470 return NULL ;
14411471 }
1442- if (options != 0 ) {
1443- reserved = options ;
1472+ if (reserved != 0 ) {
1473+ if (PyErr_WarnEx (PyExc_DeprecationWarning ,
1474+ "reserved is deprecated, use options instead." , 1 ))
1475+ {
1476+ return NULL ;
1477+ }
1478+ options = reserved ;
14441479 }
14451480 Py_BEGIN_ALLOW_THREADS
14461481 rc = RegOpenKeyExW (key , sub_key , reserved , access , & retKey );
@@ -1456,23 +1491,6 @@ winreg_OpenKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
14561491 return retKey ;
14571492}
14581493
1459- /*[clinic input]
1460- winreg.OpenKeyEx = winreg.OpenKey
1461-
1462- Opens the specified key.
1463-
1464- The result is a new handle to the specified key.
1465- If the function fails, an OSError exception is raised.
1466- [clinic start generated code]*/
1467-
1468- static HKEY
1469- winreg_OpenKeyEx_impl (PyObject * module , HKEY key , const wchar_t * sub_key ,
1470- int reserved , REGSAM access , int options )
1471- /*[clinic end generated code: output=08a607e6a6385ed4 input=c6c4972af8622959]*/
1472- {
1473- return winreg_OpenKey_impl (module , key , sub_key , reserved , access , options );
1474- }
1475-
14761494/*[clinic input]
14771495winreg.QueryInfoKey
14781496
0 commit comments