1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9 #include "pycore_long.h" // _PyLong_UnsignedLong_Converter()
10 #include "pycore_modsupport.h" // _PyArg_CheckPositional()
11
12 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
13
14 PyDoc_STRVAR(winreg_HKEYType_Close__doc__,
15 "Close($self, /)\n"
16 "--\n"
17 "\n"
18 "Closes the underlying Windows handle.\n"
19 "\n"
20 "If the handle is already closed, no error is raised.");
21
22 #define WINREG_HKEYTYPE_CLOSE_METHODDEF \
23 {"Close", (PyCFunction)winreg_HKEYType_Close, METH_NOARGS, winreg_HKEYType_Close__doc__},
24
25 static PyObject *
26 winreg_HKEYType_Close_impl(PyHKEYObject *self);
27
28 static PyObject *
winreg_HKEYType_Close(PyHKEYObject * self,PyObject * Py_UNUSED (ignored))29 winreg_HKEYType_Close(PyHKEYObject *self, PyObject *Py_UNUSED(ignored))
30 {
31 return winreg_HKEYType_Close_impl(self);
32 }
33
34 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
35
36 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
37
38 PyDoc_STRVAR(winreg_HKEYType_Detach__doc__,
39 "Detach($self, /)\n"
40 "--\n"
41 "\n"
42 "Detaches the Windows handle from the handle object.\n"
43 "\n"
44 "The result is the value of the handle before it is detached. If the\n"
45 "handle is already detached, this will return zero.\n"
46 "\n"
47 "After calling this function, the handle is effectively invalidated,\n"
48 "but the handle is not closed. You would call this function when you\n"
49 "need the underlying win32 handle to exist beyond the lifetime of the\n"
50 "handle object.");
51
52 #define WINREG_HKEYTYPE_DETACH_METHODDEF \
53 {"Detach", (PyCFunction)winreg_HKEYType_Detach, METH_NOARGS, winreg_HKEYType_Detach__doc__},
54
55 static PyObject *
56 winreg_HKEYType_Detach_impl(PyHKEYObject *self);
57
58 static PyObject *
winreg_HKEYType_Detach(PyHKEYObject * self,PyObject * Py_UNUSED (ignored))59 winreg_HKEYType_Detach(PyHKEYObject *self, PyObject *Py_UNUSED(ignored))
60 {
61 return winreg_HKEYType_Detach_impl(self);
62 }
63
64 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
65
66 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
67
68 PyDoc_STRVAR(winreg_HKEYType___enter____doc__,
69 "__enter__($self, /)\n"
70 "--\n"
71 "\n");
72
73 #define WINREG_HKEYTYPE___ENTER___METHODDEF \
74 {"__enter__", (PyCFunction)winreg_HKEYType___enter__, METH_NOARGS, winreg_HKEYType___enter____doc__},
75
76 static PyHKEYObject *
77 winreg_HKEYType___enter___impl(PyHKEYObject *self);
78
79 static PyObject *
winreg_HKEYType___enter__(PyHKEYObject * self,PyObject * Py_UNUSED (ignored))80 winreg_HKEYType___enter__(PyHKEYObject *self, PyObject *Py_UNUSED(ignored))
81 {
82 PyObject *return_value = NULL;
83 PyHKEYObject *_return_value;
84
85 _return_value = winreg_HKEYType___enter___impl(self);
86 return_value = (PyObject *)_return_value;
87
88 return return_value;
89 }
90
91 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
92
93 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
94
95 PyDoc_STRVAR(winreg_HKEYType___exit____doc__,
96 "__exit__($self, exc_type, exc_value, traceback, /)\n"
97 "--\n"
98 "\n");
99
100 #define WINREG_HKEYTYPE___EXIT___METHODDEF \
101 {"__exit__", _PyCFunction_CAST(winreg_HKEYType___exit__), METH_FASTCALL, winreg_HKEYType___exit____doc__},
102
103 static PyObject *
104 winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type,
105 PyObject *exc_value, PyObject *traceback);
106
107 static PyObject *
winreg_HKEYType___exit__(PyHKEYObject * self,PyObject * const * args,Py_ssize_t nargs)108 winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *const *args, Py_ssize_t nargs)
109 {
110 PyObject *return_value = NULL;
111 PyObject *exc_type;
112 PyObject *exc_value;
113 PyObject *traceback;
114
115 if (!_PyArg_CheckPositional("__exit__", nargs, 3, 3)) {
116 goto exit;
117 }
118 exc_type = args[0];
119 exc_value = args[1];
120 traceback = args[2];
121 return_value = winreg_HKEYType___exit___impl(self, exc_type, exc_value, traceback);
122
123 exit:
124 return return_value;
125 }
126
127 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
128
129 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
130
131 PyDoc_STRVAR(winreg_CloseKey__doc__,
132 "CloseKey($module, hkey, /)\n"
133 "--\n"
134 "\n"
135 "Closes a previously opened registry key.\n"
136 "\n"
137 " hkey\n"
138 " A previously opened key.\n"
139 "\n"
140 "Note that if the key is not closed using this method, it will be\n"
141 "closed when the hkey object is destroyed by Python.");
142
143 #define WINREG_CLOSEKEY_METHODDEF \
144 {"CloseKey", (PyCFunction)winreg_CloseKey, METH_O, winreg_CloseKey__doc__},
145
146 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
147
148 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
149
150 PyDoc_STRVAR(winreg_ConnectRegistry__doc__,
151 "ConnectRegistry($module, computer_name, key, /)\n"
152 "--\n"
153 "\n"
154 "Establishes a connection to the registry on another computer.\n"
155 "\n"
156 " computer_name\n"
157 " The name of the remote computer, of the form r\"\\\\computername\". If\n"
158 " None, the local computer is used.\n"
159 " key\n"
160 " The predefined key to connect to.\n"
161 "\n"
162 "The return value is the handle of the opened key.\n"
163 "If the function fails, an OSError exception is raised.");
164
165 #define WINREG_CONNECTREGISTRY_METHODDEF \
166 {"ConnectRegistry", _PyCFunction_CAST(winreg_ConnectRegistry), METH_FASTCALL, winreg_ConnectRegistry__doc__},
167
168 static HKEY
169 winreg_ConnectRegistry_impl(PyObject *module, const wchar_t *computer_name,
170 HKEY key);
171
172 static PyObject *
winreg_ConnectRegistry(PyObject * module,PyObject * const * args,Py_ssize_t nargs)173 winreg_ConnectRegistry(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
174 {
175 PyObject *return_value = NULL;
176 const wchar_t *computer_name = NULL;
177 HKEY key;
178 HKEY _return_value;
179
180 if (!_PyArg_CheckPositional("ConnectRegistry", nargs, 2, 2)) {
181 goto exit;
182 }
183 if (args[0] == Py_None) {
184 computer_name = NULL;
185 }
186 else if (PyUnicode_Check(args[0])) {
187 computer_name = PyUnicode_AsWideCharString(args[0], NULL);
188 if (computer_name == NULL) {
189 goto exit;
190 }
191 }
192 else {
193 _PyArg_BadArgument("ConnectRegistry", "argument 1", "str or None", args[0]);
194 goto exit;
195 }
196 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[1], &key)) {
197 goto exit;
198 }
199 _return_value = winreg_ConnectRegistry_impl(module, computer_name, key);
200 if (_return_value == NULL) {
201 goto exit;
202 }
203 return_value = PyHKEY_FromHKEY(_PyModule_GetState(module), _return_value);
204
205 exit:
206 /* Cleanup for computer_name */
207 PyMem_Free((void *)computer_name);
208
209 return return_value;
210 }
211
212 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
213
214 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
215
216 PyDoc_STRVAR(winreg_CreateKey__doc__,
217 "CreateKey($module, key, sub_key, /)\n"
218 "--\n"
219 "\n"
220 "Creates or opens the specified key.\n"
221 "\n"
222 " key\n"
223 " An already open key, or one of the predefined HKEY_* constants.\n"
224 " sub_key\n"
225 " The name of the key this method opens or creates.\n"
226 "\n"
227 "If key is one of the predefined keys, sub_key may be None. In that case,\n"
228 "the handle returned is the same key handle passed in to the function.\n"
229 "\n"
230 "If the key already exists, this function opens the existing key.\n"
231 "\n"
232 "The return value is the handle of the opened key.\n"
233 "If the function fails, an OSError exception is raised.");
234
235 #define WINREG_CREATEKEY_METHODDEF \
236 {"CreateKey", _PyCFunction_CAST(winreg_CreateKey), METH_FASTCALL, winreg_CreateKey__doc__},
237
238 static HKEY
239 winreg_CreateKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key);
240
241 static PyObject *
winreg_CreateKey(PyObject * module,PyObject * const * args,Py_ssize_t nargs)242 winreg_CreateKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
243 {
244 PyObject *return_value = NULL;
245 HKEY key;
246 const wchar_t *sub_key = NULL;
247 HKEY _return_value;
248
249 if (!_PyArg_CheckPositional("CreateKey", nargs, 2, 2)) {
250 goto exit;
251 }
252 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
253 goto exit;
254 }
255 if (args[1] == Py_None) {
256 sub_key = NULL;
257 }
258 else if (PyUnicode_Check(args[1])) {
259 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
260 if (sub_key == NULL) {
261 goto exit;
262 }
263 }
264 else {
265 _PyArg_BadArgument("CreateKey", "argument 2", "str or None", args[1]);
266 goto exit;
267 }
268 _return_value = winreg_CreateKey_impl(module, key, sub_key);
269 if (_return_value == NULL) {
270 goto exit;
271 }
272 return_value = PyHKEY_FromHKEY(_PyModule_GetState(module), _return_value);
273
274 exit:
275 /* Cleanup for sub_key */
276 PyMem_Free((void *)sub_key);
277
278 return return_value;
279 }
280
281 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
282
283 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
284
285 PyDoc_STRVAR(winreg_CreateKeyEx__doc__,
286 "CreateKeyEx($module, /, key, sub_key, reserved=0,\n"
287 " access=winreg.KEY_WRITE)\n"
288 "--\n"
289 "\n"
290 "Creates or opens the specified key.\n"
291 "\n"
292 " key\n"
293 " An already open key, or one of the predefined HKEY_* constants.\n"
294 " sub_key\n"
295 " The name of the key this method opens or creates.\n"
296 " reserved\n"
297 " A reserved integer, and must be zero. Default is zero.\n"
298 " access\n"
299 " An integer that specifies an access mask that describes the\n"
300 " desired security access for the key. Default is KEY_WRITE.\n"
301 "\n"
302 "If key is one of the predefined keys, sub_key may be None. In that case,\n"
303 "the handle returned is the same key handle passed in to the function.\n"
304 "\n"
305 "If the key already exists, this function opens the existing key\n"
306 "\n"
307 "The return value is the handle of the opened key.\n"
308 "If the function fails, an OSError exception is raised.");
309
310 #define WINREG_CREATEKEYEX_METHODDEF \
311 {"CreateKeyEx", _PyCFunction_CAST(winreg_CreateKeyEx), METH_FASTCALL|METH_KEYWORDS, winreg_CreateKeyEx__doc__},
312
313 static HKEY
314 winreg_CreateKeyEx_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
315 int reserved, REGSAM access);
316
317 static PyObject *
winreg_CreateKeyEx(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)318 winreg_CreateKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
319 {
320 PyObject *return_value = NULL;
321 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
322
323 #define NUM_KEYWORDS 4
324 static struct {
325 PyGC_Head _this_is_not_used;
326 PyObject_VAR_HEAD
327 PyObject *ob_item[NUM_KEYWORDS];
328 } _kwtuple = {
329 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
330 .ob_item = { &_Py_ID(key), &_Py_ID(sub_key), &_Py_ID(reserved), &_Py_ID(access), },
331 };
332 #undef NUM_KEYWORDS
333 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
334
335 #else // !Py_BUILD_CORE
336 # define KWTUPLE NULL
337 #endif // !Py_BUILD_CORE
338
339 static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
340 static _PyArg_Parser _parser = {
341 .keywords = _keywords,
342 .fname = "CreateKeyEx",
343 .kwtuple = KWTUPLE,
344 };
345 #undef KWTUPLE
346 PyObject *argsbuf[4];
347 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
348 HKEY key;
349 const wchar_t *sub_key = NULL;
350 int reserved = 0;
351 REGSAM access = KEY_WRITE;
352 HKEY _return_value;
353
354 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf);
355 if (!args) {
356 goto exit;
357 }
358 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
359 goto exit;
360 }
361 if (args[1] == Py_None) {
362 sub_key = NULL;
363 }
364 else if (PyUnicode_Check(args[1])) {
365 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
366 if (sub_key == NULL) {
367 goto exit;
368 }
369 }
370 else {
371 _PyArg_BadArgument("CreateKeyEx", "argument 'sub_key'", "str or None", args[1]);
372 goto exit;
373 }
374 if (!noptargs) {
375 goto skip_optional_pos;
376 }
377 if (args[2]) {
378 reserved = PyLong_AsInt(args[2]);
379 if (reserved == -1 && PyErr_Occurred()) {
380 goto exit;
381 }
382 if (!--noptargs) {
383 goto skip_optional_pos;
384 }
385 }
386 access = PyLong_AsInt(args[3]);
387 if (access == -1 && PyErr_Occurred()) {
388 goto exit;
389 }
390 skip_optional_pos:
391 _return_value = winreg_CreateKeyEx_impl(module, key, sub_key, reserved, access);
392 if (_return_value == NULL) {
393 goto exit;
394 }
395 return_value = PyHKEY_FromHKEY(_PyModule_GetState(module), _return_value);
396
397 exit:
398 /* Cleanup for sub_key */
399 PyMem_Free((void *)sub_key);
400
401 return return_value;
402 }
403
404 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
405
406 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
407
408 PyDoc_STRVAR(winreg_DeleteKey__doc__,
409 "DeleteKey($module, key, sub_key, /)\n"
410 "--\n"
411 "\n"
412 "Deletes the specified key.\n"
413 "\n"
414 " key\n"
415 " An already open key, or any one of the predefined HKEY_* constants.\n"
416 " sub_key\n"
417 " A string that must be the name of a subkey of the key identified by\n"
418 " the key parameter. This value must not be None, and the key may not\n"
419 " have subkeys.\n"
420 "\n"
421 "This method can not delete keys with subkeys.\n"
422 "\n"
423 "If the function succeeds, the entire key, including all of its values,\n"
424 "is removed. If the function fails, an OSError exception is raised.");
425
426 #define WINREG_DELETEKEY_METHODDEF \
427 {"DeleteKey", _PyCFunction_CAST(winreg_DeleteKey), METH_FASTCALL, winreg_DeleteKey__doc__},
428
429 static PyObject *
430 winreg_DeleteKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key);
431
432 static PyObject *
winreg_DeleteKey(PyObject * module,PyObject * const * args,Py_ssize_t nargs)433 winreg_DeleteKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
434 {
435 PyObject *return_value = NULL;
436 HKEY key;
437 const wchar_t *sub_key = NULL;
438
439 if (!_PyArg_CheckPositional("DeleteKey", nargs, 2, 2)) {
440 goto exit;
441 }
442 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
443 goto exit;
444 }
445 if (!PyUnicode_Check(args[1])) {
446 _PyArg_BadArgument("DeleteKey", "argument 2", "str", args[1]);
447 goto exit;
448 }
449 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
450 if (sub_key == NULL) {
451 goto exit;
452 }
453 return_value = winreg_DeleteKey_impl(module, key, sub_key);
454
455 exit:
456 /* Cleanup for sub_key */
457 PyMem_Free((void *)sub_key);
458
459 return return_value;
460 }
461
462 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
463
464 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
465
466 PyDoc_STRVAR(winreg_DeleteKeyEx__doc__,
467 "DeleteKeyEx($module, /, key, sub_key, access=winreg.KEY_WOW64_64KEY,\n"
468 " reserved=0)\n"
469 "--\n"
470 "\n"
471 "Deletes the specified key (intended for 64-bit OS).\n"
472 "\n"
473 " key\n"
474 " An already open key, or any one of the predefined HKEY_* constants.\n"
475 " sub_key\n"
476 " A string that must be the name of a subkey of the key identified by\n"
477 " the key parameter. This value must not be None, and the key may not\n"
478 " have subkeys.\n"
479 " access\n"
480 " An integer that specifies an access mask that describes the\n"
481 " desired security access for the key. Default is KEY_WOW64_64KEY.\n"
482 " reserved\n"
483 " A reserved integer, and must be zero. Default is zero.\n"
484 "\n"
485 "While this function is intended to be used for 64-bit OS, it is also\n"
486 " available on 32-bit systems.\n"
487 "\n"
488 "This method can not delete keys with subkeys.\n"
489 "\n"
490 "If the function succeeds, the entire key, including all of its values,\n"
491 "is removed. If the function fails, an OSError exception is raised.\n"
492 "On unsupported Windows versions, NotImplementedError is raised.");
493
494 #define WINREG_DELETEKEYEX_METHODDEF \
495 {"DeleteKeyEx", _PyCFunction_CAST(winreg_DeleteKeyEx), METH_FASTCALL|METH_KEYWORDS, winreg_DeleteKeyEx__doc__},
496
497 static PyObject *
498 winreg_DeleteKeyEx_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
499 REGSAM access, int reserved);
500
501 static PyObject *
winreg_DeleteKeyEx(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)502 winreg_DeleteKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
503 {
504 PyObject *return_value = NULL;
505 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
506
507 #define NUM_KEYWORDS 4
508 static struct {
509 PyGC_Head _this_is_not_used;
510 PyObject_VAR_HEAD
511 PyObject *ob_item[NUM_KEYWORDS];
512 } _kwtuple = {
513 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
514 .ob_item = { &_Py_ID(key), &_Py_ID(sub_key), &_Py_ID(access), &_Py_ID(reserved), },
515 };
516 #undef NUM_KEYWORDS
517 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
518
519 #else // !Py_BUILD_CORE
520 # define KWTUPLE NULL
521 #endif // !Py_BUILD_CORE
522
523 static const char * const _keywords[] = {"key", "sub_key", "access", "reserved", NULL};
524 static _PyArg_Parser _parser = {
525 .keywords = _keywords,
526 .fname = "DeleteKeyEx",
527 .kwtuple = KWTUPLE,
528 };
529 #undef KWTUPLE
530 PyObject *argsbuf[4];
531 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
532 HKEY key;
533 const wchar_t *sub_key = NULL;
534 REGSAM access = KEY_WOW64_64KEY;
535 int reserved = 0;
536
537 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf);
538 if (!args) {
539 goto exit;
540 }
541 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
542 goto exit;
543 }
544 if (!PyUnicode_Check(args[1])) {
545 _PyArg_BadArgument("DeleteKeyEx", "argument 'sub_key'", "str", args[1]);
546 goto exit;
547 }
548 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
549 if (sub_key == NULL) {
550 goto exit;
551 }
552 if (!noptargs) {
553 goto skip_optional_pos;
554 }
555 if (args[2]) {
556 access = PyLong_AsInt(args[2]);
557 if (access == -1 && PyErr_Occurred()) {
558 goto exit;
559 }
560 if (!--noptargs) {
561 goto skip_optional_pos;
562 }
563 }
564 reserved = PyLong_AsInt(args[3]);
565 if (reserved == -1 && PyErr_Occurred()) {
566 goto exit;
567 }
568 skip_optional_pos:
569 return_value = winreg_DeleteKeyEx_impl(module, key, sub_key, access, reserved);
570
571 exit:
572 /* Cleanup for sub_key */
573 PyMem_Free((void *)sub_key);
574
575 return return_value;
576 }
577
578 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
579
580 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
581
582 PyDoc_STRVAR(winreg_DeleteValue__doc__,
583 "DeleteValue($module, key, value, /)\n"
584 "--\n"
585 "\n"
586 "Removes a named value from a registry key.\n"
587 "\n"
588 " key\n"
589 " An already open key, or any one of the predefined HKEY_* constants.\n"
590 " value\n"
591 " A string that identifies the value to remove.");
592
593 #define WINREG_DELETEVALUE_METHODDEF \
594 {"DeleteValue", _PyCFunction_CAST(winreg_DeleteValue), METH_FASTCALL, winreg_DeleteValue__doc__},
595
596 static PyObject *
597 winreg_DeleteValue_impl(PyObject *module, HKEY key, const wchar_t *value);
598
599 static PyObject *
winreg_DeleteValue(PyObject * module,PyObject * const * args,Py_ssize_t nargs)600 winreg_DeleteValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
601 {
602 PyObject *return_value = NULL;
603 HKEY key;
604 const wchar_t *value = NULL;
605
606 if (!_PyArg_CheckPositional("DeleteValue", nargs, 2, 2)) {
607 goto exit;
608 }
609 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
610 goto exit;
611 }
612 if (args[1] == Py_None) {
613 value = NULL;
614 }
615 else if (PyUnicode_Check(args[1])) {
616 value = PyUnicode_AsWideCharString(args[1], NULL);
617 if (value == NULL) {
618 goto exit;
619 }
620 }
621 else {
622 _PyArg_BadArgument("DeleteValue", "argument 2", "str or None", args[1]);
623 goto exit;
624 }
625 return_value = winreg_DeleteValue_impl(module, key, value);
626
627 exit:
628 /* Cleanup for value */
629 PyMem_Free((void *)value);
630
631 return return_value;
632 }
633
634 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
635
636 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
637
638 PyDoc_STRVAR(winreg_EnumKey__doc__,
639 "EnumKey($module, key, index, /)\n"
640 "--\n"
641 "\n"
642 "Enumerates subkeys of an open registry key.\n"
643 "\n"
644 " key\n"
645 " An already open key, or any one of the predefined HKEY_* constants.\n"
646 " index\n"
647 " An integer that identifies the index of the key to retrieve.\n"
648 "\n"
649 "The function retrieves the name of one subkey each time it is called.\n"
650 "It is typically called repeatedly until an OSError exception is\n"
651 "raised, indicating no more values are available.");
652
653 #define WINREG_ENUMKEY_METHODDEF \
654 {"EnumKey", _PyCFunction_CAST(winreg_EnumKey), METH_FASTCALL, winreg_EnumKey__doc__},
655
656 static PyObject *
657 winreg_EnumKey_impl(PyObject *module, HKEY key, int index);
658
659 static PyObject *
winreg_EnumKey(PyObject * module,PyObject * const * args,Py_ssize_t nargs)660 winreg_EnumKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
661 {
662 PyObject *return_value = NULL;
663 HKEY key;
664 int index;
665
666 if (!_PyArg_CheckPositional("EnumKey", nargs, 2, 2)) {
667 goto exit;
668 }
669 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
670 goto exit;
671 }
672 index = PyLong_AsInt(args[1]);
673 if (index == -1 && PyErr_Occurred()) {
674 goto exit;
675 }
676 return_value = winreg_EnumKey_impl(module, key, index);
677
678 exit:
679 return return_value;
680 }
681
682 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
683
684 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
685
686 PyDoc_STRVAR(winreg_EnumValue__doc__,
687 "EnumValue($module, key, index, /)\n"
688 "--\n"
689 "\n"
690 "Enumerates values of an open registry key.\n"
691 "\n"
692 " key\n"
693 " An already open key, or any one of the predefined HKEY_* constants.\n"
694 " index\n"
695 " An integer that identifies the index of the value to retrieve.\n"
696 "\n"
697 "The function retrieves the name of one subkey each time it is called.\n"
698 "It is typically called repeatedly, until an OSError exception\n"
699 "is raised, indicating no more values.\n"
700 "\n"
701 "The result is a tuple of 3 items:\n"
702 " value_name\n"
703 " A string that identifies the value.\n"
704 " value_data\n"
705 " An object that holds the value data, and whose type depends\n"
706 " on the underlying registry type.\n"
707 " data_type\n"
708 " An integer that identifies the type of the value data.");
709
710 #define WINREG_ENUMVALUE_METHODDEF \
711 {"EnumValue", _PyCFunction_CAST(winreg_EnumValue), METH_FASTCALL, winreg_EnumValue__doc__},
712
713 static PyObject *
714 winreg_EnumValue_impl(PyObject *module, HKEY key, int index);
715
716 static PyObject *
winreg_EnumValue(PyObject * module,PyObject * const * args,Py_ssize_t nargs)717 winreg_EnumValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
718 {
719 PyObject *return_value = NULL;
720 HKEY key;
721 int index;
722
723 if (!_PyArg_CheckPositional("EnumValue", nargs, 2, 2)) {
724 goto exit;
725 }
726 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
727 goto exit;
728 }
729 index = PyLong_AsInt(args[1]);
730 if (index == -1 && PyErr_Occurred()) {
731 goto exit;
732 }
733 return_value = winreg_EnumValue_impl(module, key, index);
734
735 exit:
736 return return_value;
737 }
738
739 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
740
741 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
742
743 PyDoc_STRVAR(winreg_ExpandEnvironmentStrings__doc__,
744 "ExpandEnvironmentStrings($module, string, /)\n"
745 "--\n"
746 "\n"
747 "Expand environment vars.");
748
749 #define WINREG_EXPANDENVIRONMENTSTRINGS_METHODDEF \
750 {"ExpandEnvironmentStrings", (PyCFunction)winreg_ExpandEnvironmentStrings, METH_O, winreg_ExpandEnvironmentStrings__doc__},
751
752 static PyObject *
753 winreg_ExpandEnvironmentStrings_impl(PyObject *module, const wchar_t *string);
754
755 static PyObject *
winreg_ExpandEnvironmentStrings(PyObject * module,PyObject * arg)756 winreg_ExpandEnvironmentStrings(PyObject *module, PyObject *arg)
757 {
758 PyObject *return_value = NULL;
759 const wchar_t *string = NULL;
760
761 if (!PyUnicode_Check(arg)) {
762 _PyArg_BadArgument("ExpandEnvironmentStrings", "argument", "str", arg);
763 goto exit;
764 }
765 string = PyUnicode_AsWideCharString(arg, NULL);
766 if (string == NULL) {
767 goto exit;
768 }
769 return_value = winreg_ExpandEnvironmentStrings_impl(module, string);
770
771 exit:
772 /* Cleanup for string */
773 PyMem_Free((void *)string);
774
775 return return_value;
776 }
777
778 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
779
780 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
781
782 PyDoc_STRVAR(winreg_FlushKey__doc__,
783 "FlushKey($module, key, /)\n"
784 "--\n"
785 "\n"
786 "Writes all the attributes of a key to the registry.\n"
787 "\n"
788 " key\n"
789 " An already open key, or any one of the predefined HKEY_* constants.\n"
790 "\n"
791 "It is not necessary to call FlushKey to change a key. Registry changes\n"
792 "are flushed to disk by the registry using its lazy flusher. Registry\n"
793 "changes are also flushed to disk at system shutdown. Unlike\n"
794 "CloseKey(), the FlushKey() method returns only when all the data has\n"
795 "been written to the registry.\n"
796 "\n"
797 "An application should only call FlushKey() if it requires absolute\n"
798 "certainty that registry changes are on disk. If you don\'t know whether\n"
799 "a FlushKey() call is required, it probably isn\'t.");
800
801 #define WINREG_FLUSHKEY_METHODDEF \
802 {"FlushKey", (PyCFunction)winreg_FlushKey, METH_O, winreg_FlushKey__doc__},
803
804 static PyObject *
805 winreg_FlushKey_impl(PyObject *module, HKEY key);
806
807 static PyObject *
winreg_FlushKey(PyObject * module,PyObject * arg)808 winreg_FlushKey(PyObject *module, PyObject *arg)
809 {
810 PyObject *return_value = NULL;
811 HKEY key;
812
813 if (!clinic_HKEY_converter(_PyModule_GetState(module), arg, &key)) {
814 goto exit;
815 }
816 return_value = winreg_FlushKey_impl(module, key);
817
818 exit:
819 return return_value;
820 }
821
822 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
823
824 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
825
826 PyDoc_STRVAR(winreg_LoadKey__doc__,
827 "LoadKey($module, key, sub_key, file_name, /)\n"
828 "--\n"
829 "\n"
830 "Insert data into the registry from a file.\n"
831 "\n"
832 " key\n"
833 " An already open key, or any one of the predefined HKEY_* constants.\n"
834 " sub_key\n"
835 " A string that identifies the sub-key to load.\n"
836 " file_name\n"
837 " The name of the file to load registry data from. This file must\n"
838 " have been created with the SaveKey() function. Under the file\n"
839 " allocation table (FAT) file system, the filename may not have an\n"
840 " extension.\n"
841 "\n"
842 "Creates a subkey under the specified key and stores registration\n"
843 "information from a specified file into that subkey.\n"
844 "\n"
845 "A call to LoadKey() fails if the calling process does not have the\n"
846 "SE_RESTORE_PRIVILEGE privilege.\n"
847 "\n"
848 "If key is a handle returned by ConnectRegistry(), then the path\n"
849 "specified in fileName is relative to the remote computer.\n"
850 "\n"
851 "The MSDN docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE\n"
852 "tree.");
853
854 #define WINREG_LOADKEY_METHODDEF \
855 {"LoadKey", _PyCFunction_CAST(winreg_LoadKey), METH_FASTCALL, winreg_LoadKey__doc__},
856
857 static PyObject *
858 winreg_LoadKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
859 const wchar_t *file_name);
860
861 static PyObject *
winreg_LoadKey(PyObject * module,PyObject * const * args,Py_ssize_t nargs)862 winreg_LoadKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
863 {
864 PyObject *return_value = NULL;
865 HKEY key;
866 const wchar_t *sub_key = NULL;
867 const wchar_t *file_name = NULL;
868
869 if (!_PyArg_CheckPositional("LoadKey", nargs, 3, 3)) {
870 goto exit;
871 }
872 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
873 goto exit;
874 }
875 if (!PyUnicode_Check(args[1])) {
876 _PyArg_BadArgument("LoadKey", "argument 2", "str", args[1]);
877 goto exit;
878 }
879 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
880 if (sub_key == NULL) {
881 goto exit;
882 }
883 if (!PyUnicode_Check(args[2])) {
884 _PyArg_BadArgument("LoadKey", "argument 3", "str", args[2]);
885 goto exit;
886 }
887 file_name = PyUnicode_AsWideCharString(args[2], NULL);
888 if (file_name == NULL) {
889 goto exit;
890 }
891 return_value = winreg_LoadKey_impl(module, key, sub_key, file_name);
892
893 exit:
894 /* Cleanup for sub_key */
895 PyMem_Free((void *)sub_key);
896 /* Cleanup for file_name */
897 PyMem_Free((void *)file_name);
898
899 return return_value;
900 }
901
902 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
903
904 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
905
906 PyDoc_STRVAR(winreg_OpenKey__doc__,
907 "OpenKey($module, /, key, sub_key, reserved=0, access=winreg.KEY_READ)\n"
908 "--\n"
909 "\n"
910 "Opens the specified key.\n"
911 "\n"
912 " key\n"
913 " An already open key, or any one of the predefined HKEY_* constants.\n"
914 " sub_key\n"
915 " A string that identifies the sub_key to open.\n"
916 " reserved\n"
917 " A reserved integer that must be zero. Default is zero.\n"
918 " access\n"
919 " An integer that specifies an access mask that describes the desired\n"
920 " security access for the key. Default is KEY_READ.\n"
921 "\n"
922 "The result is a new handle to the specified key.\n"
923 "If the function fails, an OSError exception is raised.");
924
925 #define WINREG_OPENKEY_METHODDEF \
926 {"OpenKey", _PyCFunction_CAST(winreg_OpenKey), METH_FASTCALL|METH_KEYWORDS, winreg_OpenKey__doc__},
927
928 static HKEY
929 winreg_OpenKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
930 int reserved, REGSAM access);
931
932 static PyObject *
winreg_OpenKey(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)933 winreg_OpenKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
934 {
935 PyObject *return_value = NULL;
936 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
937
938 #define NUM_KEYWORDS 4
939 static struct {
940 PyGC_Head _this_is_not_used;
941 PyObject_VAR_HEAD
942 PyObject *ob_item[NUM_KEYWORDS];
943 } _kwtuple = {
944 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
945 .ob_item = { &_Py_ID(key), &_Py_ID(sub_key), &_Py_ID(reserved), &_Py_ID(access), },
946 };
947 #undef NUM_KEYWORDS
948 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
949
950 #else // !Py_BUILD_CORE
951 # define KWTUPLE NULL
952 #endif // !Py_BUILD_CORE
953
954 static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
955 static _PyArg_Parser _parser = {
956 .keywords = _keywords,
957 .fname = "OpenKey",
958 .kwtuple = KWTUPLE,
959 };
960 #undef KWTUPLE
961 PyObject *argsbuf[4];
962 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
963 HKEY key;
964 const wchar_t *sub_key = NULL;
965 int reserved = 0;
966 REGSAM access = KEY_READ;
967 HKEY _return_value;
968
969 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf);
970 if (!args) {
971 goto exit;
972 }
973 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
974 goto exit;
975 }
976 if (args[1] == Py_None) {
977 sub_key = NULL;
978 }
979 else if (PyUnicode_Check(args[1])) {
980 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
981 if (sub_key == NULL) {
982 goto exit;
983 }
984 }
985 else {
986 _PyArg_BadArgument("OpenKey", "argument 'sub_key'", "str or None", args[1]);
987 goto exit;
988 }
989 if (!noptargs) {
990 goto skip_optional_pos;
991 }
992 if (args[2]) {
993 reserved = PyLong_AsInt(args[2]);
994 if (reserved == -1 && PyErr_Occurred()) {
995 goto exit;
996 }
997 if (!--noptargs) {
998 goto skip_optional_pos;
999 }
1000 }
1001 access = PyLong_AsInt(args[3]);
1002 if (access == -1 && PyErr_Occurred()) {
1003 goto exit;
1004 }
1005 skip_optional_pos:
1006 _return_value = winreg_OpenKey_impl(module, key, sub_key, reserved, access);
1007 if (_return_value == NULL) {
1008 goto exit;
1009 }
1010 return_value = PyHKEY_FromHKEY(_PyModule_GetState(module), _return_value);
1011
1012 exit:
1013 /* Cleanup for sub_key */
1014 PyMem_Free((void *)sub_key);
1015
1016 return return_value;
1017 }
1018
1019 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
1020
1021 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
1022
1023 PyDoc_STRVAR(winreg_OpenKeyEx__doc__,
1024 "OpenKeyEx($module, /, key, sub_key, reserved=0, access=winreg.KEY_READ)\n"
1025 "--\n"
1026 "\n"
1027 "Opens the specified key.\n"
1028 "\n"
1029 " key\n"
1030 " An already open key, or any one of the predefined HKEY_* constants.\n"
1031 " sub_key\n"
1032 " A string that identifies the sub_key to open.\n"
1033 " reserved\n"
1034 " A reserved integer that must be zero. Default is zero.\n"
1035 " access\n"
1036 " An integer that specifies an access mask that describes the desired\n"
1037 " security access for the key. Default is KEY_READ.\n"
1038 "\n"
1039 "The result is a new handle to the specified key.\n"
1040 "If the function fails, an OSError exception is raised.");
1041
1042 #define WINREG_OPENKEYEX_METHODDEF \
1043 {"OpenKeyEx", _PyCFunction_CAST(winreg_OpenKeyEx), METH_FASTCALL|METH_KEYWORDS, winreg_OpenKeyEx__doc__},
1044
1045 static HKEY
1046 winreg_OpenKeyEx_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
1047 int reserved, REGSAM access);
1048
1049 static PyObject *
winreg_OpenKeyEx(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)1050 winreg_OpenKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1051 {
1052 PyObject *return_value = NULL;
1053 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1054
1055 #define NUM_KEYWORDS 4
1056 static struct {
1057 PyGC_Head _this_is_not_used;
1058 PyObject_VAR_HEAD
1059 PyObject *ob_item[NUM_KEYWORDS];
1060 } _kwtuple = {
1061 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1062 .ob_item = { &_Py_ID(key), &_Py_ID(sub_key), &_Py_ID(reserved), &_Py_ID(access), },
1063 };
1064 #undef NUM_KEYWORDS
1065 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1066
1067 #else // !Py_BUILD_CORE
1068 # define KWTUPLE NULL
1069 #endif // !Py_BUILD_CORE
1070
1071 static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
1072 static _PyArg_Parser _parser = {
1073 .keywords = _keywords,
1074 .fname = "OpenKeyEx",
1075 .kwtuple = KWTUPLE,
1076 };
1077 #undef KWTUPLE
1078 PyObject *argsbuf[4];
1079 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
1080 HKEY key;
1081 const wchar_t *sub_key = NULL;
1082 int reserved = 0;
1083 REGSAM access = KEY_READ;
1084 HKEY _return_value;
1085
1086 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf);
1087 if (!args) {
1088 goto exit;
1089 }
1090 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
1091 goto exit;
1092 }
1093 if (args[1] == Py_None) {
1094 sub_key = NULL;
1095 }
1096 else if (PyUnicode_Check(args[1])) {
1097 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
1098 if (sub_key == NULL) {
1099 goto exit;
1100 }
1101 }
1102 else {
1103 _PyArg_BadArgument("OpenKeyEx", "argument 'sub_key'", "str or None", args[1]);
1104 goto exit;
1105 }
1106 if (!noptargs) {
1107 goto skip_optional_pos;
1108 }
1109 if (args[2]) {
1110 reserved = PyLong_AsInt(args[2]);
1111 if (reserved == -1 && PyErr_Occurred()) {
1112 goto exit;
1113 }
1114 if (!--noptargs) {
1115 goto skip_optional_pos;
1116 }
1117 }
1118 access = PyLong_AsInt(args[3]);
1119 if (access == -1 && PyErr_Occurred()) {
1120 goto exit;
1121 }
1122 skip_optional_pos:
1123 _return_value = winreg_OpenKeyEx_impl(module, key, sub_key, reserved, access);
1124 if (_return_value == NULL) {
1125 goto exit;
1126 }
1127 return_value = PyHKEY_FromHKEY(_PyModule_GetState(module), _return_value);
1128
1129 exit:
1130 /* Cleanup for sub_key */
1131 PyMem_Free((void *)sub_key);
1132
1133 return return_value;
1134 }
1135
1136 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
1137
1138 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
1139
1140 PyDoc_STRVAR(winreg_QueryInfoKey__doc__,
1141 "QueryInfoKey($module, key, /)\n"
1142 "--\n"
1143 "\n"
1144 "Returns information about a key.\n"
1145 "\n"
1146 " key\n"
1147 " An already open key, or any one of the predefined HKEY_* constants.\n"
1148 "\n"
1149 "The result is a tuple of 3 items:\n"
1150 "An integer that identifies the number of sub keys this key has.\n"
1151 "An integer that identifies the number of values this key has.\n"
1152 "An integer that identifies when the key was last modified (if available)\n"
1153 "as 100\'s of nanoseconds since Jan 1, 1600.");
1154
1155 #define WINREG_QUERYINFOKEY_METHODDEF \
1156 {"QueryInfoKey", (PyCFunction)winreg_QueryInfoKey, METH_O, winreg_QueryInfoKey__doc__},
1157
1158 static PyObject *
1159 winreg_QueryInfoKey_impl(PyObject *module, HKEY key);
1160
1161 static PyObject *
winreg_QueryInfoKey(PyObject * module,PyObject * arg)1162 winreg_QueryInfoKey(PyObject *module, PyObject *arg)
1163 {
1164 PyObject *return_value = NULL;
1165 HKEY key;
1166
1167 if (!clinic_HKEY_converter(_PyModule_GetState(module), arg, &key)) {
1168 goto exit;
1169 }
1170 return_value = winreg_QueryInfoKey_impl(module, key);
1171
1172 exit:
1173 return return_value;
1174 }
1175
1176 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
1177
1178 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
1179
1180 PyDoc_STRVAR(winreg_QueryValue__doc__,
1181 "QueryValue($module, key, sub_key, /)\n"
1182 "--\n"
1183 "\n"
1184 "Retrieves the unnamed value for a key.\n"
1185 "\n"
1186 " key\n"
1187 " An already open key, or any one of the predefined HKEY_* constants.\n"
1188 " sub_key\n"
1189 " A string that holds the name of the subkey with which the value\n"
1190 " is associated. If this parameter is None or empty, the function\n"
1191 " retrieves the value set by the SetValue() method for the key\n"
1192 " identified by key.\n"
1193 "\n"
1194 "Values in the registry have name, type, and data components. This method\n"
1195 "retrieves the data for a key\'s first value that has a NULL name.\n"
1196 "But since the underlying API call doesn\'t return the type, you\'ll\n"
1197 "probably be happier using QueryValueEx; this function is just here for\n"
1198 "completeness.");
1199
1200 #define WINREG_QUERYVALUE_METHODDEF \
1201 {"QueryValue", _PyCFunction_CAST(winreg_QueryValue), METH_FASTCALL, winreg_QueryValue__doc__},
1202
1203 static PyObject *
1204 winreg_QueryValue_impl(PyObject *module, HKEY key, const wchar_t *sub_key);
1205
1206 static PyObject *
winreg_QueryValue(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1207 winreg_QueryValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1208 {
1209 PyObject *return_value = NULL;
1210 HKEY key;
1211 const wchar_t *sub_key = NULL;
1212
1213 if (!_PyArg_CheckPositional("QueryValue", nargs, 2, 2)) {
1214 goto exit;
1215 }
1216 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
1217 goto exit;
1218 }
1219 if (args[1] == Py_None) {
1220 sub_key = NULL;
1221 }
1222 else if (PyUnicode_Check(args[1])) {
1223 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
1224 if (sub_key == NULL) {
1225 goto exit;
1226 }
1227 }
1228 else {
1229 _PyArg_BadArgument("QueryValue", "argument 2", "str or None", args[1]);
1230 goto exit;
1231 }
1232 return_value = winreg_QueryValue_impl(module, key, sub_key);
1233
1234 exit:
1235 /* Cleanup for sub_key */
1236 PyMem_Free((void *)sub_key);
1237
1238 return return_value;
1239 }
1240
1241 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
1242
1243 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
1244
1245 PyDoc_STRVAR(winreg_QueryValueEx__doc__,
1246 "QueryValueEx($module, key, name, /)\n"
1247 "--\n"
1248 "\n"
1249 "Retrieves the type and value of a specified sub-key.\n"
1250 "\n"
1251 " key\n"
1252 " An already open key, or any one of the predefined HKEY_* constants.\n"
1253 " name\n"
1254 " A string indicating the value to query.\n"
1255 "\n"
1256 "Behaves mostly like QueryValue(), but also returns the type of the\n"
1257 "specified value name associated with the given open registry key.\n"
1258 "\n"
1259 "The return value is a tuple of the value and the type_id.");
1260
1261 #define WINREG_QUERYVALUEEX_METHODDEF \
1262 {"QueryValueEx", _PyCFunction_CAST(winreg_QueryValueEx), METH_FASTCALL, winreg_QueryValueEx__doc__},
1263
1264 static PyObject *
1265 winreg_QueryValueEx_impl(PyObject *module, HKEY key, const wchar_t *name);
1266
1267 static PyObject *
winreg_QueryValueEx(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1268 winreg_QueryValueEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1269 {
1270 PyObject *return_value = NULL;
1271 HKEY key;
1272 const wchar_t *name = NULL;
1273
1274 if (!_PyArg_CheckPositional("QueryValueEx", nargs, 2, 2)) {
1275 goto exit;
1276 }
1277 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
1278 goto exit;
1279 }
1280 if (args[1] == Py_None) {
1281 name = NULL;
1282 }
1283 else if (PyUnicode_Check(args[1])) {
1284 name = PyUnicode_AsWideCharString(args[1], NULL);
1285 if (name == NULL) {
1286 goto exit;
1287 }
1288 }
1289 else {
1290 _PyArg_BadArgument("QueryValueEx", "argument 2", "str or None", args[1]);
1291 goto exit;
1292 }
1293 return_value = winreg_QueryValueEx_impl(module, key, name);
1294
1295 exit:
1296 /* Cleanup for name */
1297 PyMem_Free((void *)name);
1298
1299 return return_value;
1300 }
1301
1302 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
1303
1304 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
1305
1306 PyDoc_STRVAR(winreg_SaveKey__doc__,
1307 "SaveKey($module, key, file_name, /)\n"
1308 "--\n"
1309 "\n"
1310 "Saves the specified key, and all its subkeys to the specified file.\n"
1311 "\n"
1312 " key\n"
1313 " An already open key, or any one of the predefined HKEY_* constants.\n"
1314 " file_name\n"
1315 " The name of the file to save registry data to. This file cannot\n"
1316 " already exist. If this filename includes an extension, it cannot be\n"
1317 " used on file allocation table (FAT) file systems by the LoadKey(),\n"
1318 " ReplaceKey() or RestoreKey() methods.\n"
1319 "\n"
1320 "If key represents a key on a remote computer, the path described by\n"
1321 "file_name is relative to the remote computer.\n"
1322 "\n"
1323 "The caller of this method must possess the SeBackupPrivilege\n"
1324 "security privilege. This function passes NULL for security_attributes\n"
1325 "to the API.");
1326
1327 #define WINREG_SAVEKEY_METHODDEF \
1328 {"SaveKey", _PyCFunction_CAST(winreg_SaveKey), METH_FASTCALL, winreg_SaveKey__doc__},
1329
1330 static PyObject *
1331 winreg_SaveKey_impl(PyObject *module, HKEY key, const wchar_t *file_name);
1332
1333 static PyObject *
winreg_SaveKey(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1334 winreg_SaveKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1335 {
1336 PyObject *return_value = NULL;
1337 HKEY key;
1338 const wchar_t *file_name = NULL;
1339
1340 if (!_PyArg_CheckPositional("SaveKey", nargs, 2, 2)) {
1341 goto exit;
1342 }
1343 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
1344 goto exit;
1345 }
1346 if (!PyUnicode_Check(args[1])) {
1347 _PyArg_BadArgument("SaveKey", "argument 2", "str", args[1]);
1348 goto exit;
1349 }
1350 file_name = PyUnicode_AsWideCharString(args[1], NULL);
1351 if (file_name == NULL) {
1352 goto exit;
1353 }
1354 return_value = winreg_SaveKey_impl(module, key, file_name);
1355
1356 exit:
1357 /* Cleanup for file_name */
1358 PyMem_Free((void *)file_name);
1359
1360 return return_value;
1361 }
1362
1363 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
1364
1365 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
1366
1367 PyDoc_STRVAR(winreg_SetValue__doc__,
1368 "SetValue($module, key, sub_key, type, value, /)\n"
1369 "--\n"
1370 "\n"
1371 "Associates a value with a specified key.\n"
1372 "\n"
1373 " key\n"
1374 " An already open key, or any one of the predefined HKEY_* constants.\n"
1375 " sub_key\n"
1376 " A string that names the subkey with which the value is associated.\n"
1377 " type\n"
1378 " An integer that specifies the type of the data. Currently this must\n"
1379 " be REG_SZ, meaning only strings are supported.\n"
1380 " value\n"
1381 " A string that specifies the new value.\n"
1382 "\n"
1383 "If the key specified by the sub_key parameter does not exist, the\n"
1384 "SetValue function creates it.\n"
1385 "\n"
1386 "Value lengths are limited by available memory. Long values (more than\n"
1387 "2048 bytes) should be stored as files with the filenames stored in\n"
1388 "the configuration registry to help the registry perform efficiently.\n"
1389 "\n"
1390 "The key identified by the key parameter must have been opened with\n"
1391 "KEY_SET_VALUE access.");
1392
1393 #define WINREG_SETVALUE_METHODDEF \
1394 {"SetValue", _PyCFunction_CAST(winreg_SetValue), METH_FASTCALL, winreg_SetValue__doc__},
1395
1396 static PyObject *
1397 winreg_SetValue_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
1398 DWORD type, PyObject *value_obj);
1399
1400 static PyObject *
winreg_SetValue(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1401 winreg_SetValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1402 {
1403 PyObject *return_value = NULL;
1404 HKEY key;
1405 const wchar_t *sub_key = NULL;
1406 DWORD type;
1407 PyObject *value_obj;
1408
1409 if (!_PyArg_CheckPositional("SetValue", nargs, 4, 4)) {
1410 goto exit;
1411 }
1412 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
1413 goto exit;
1414 }
1415 if (args[1] == Py_None) {
1416 sub_key = NULL;
1417 }
1418 else if (PyUnicode_Check(args[1])) {
1419 sub_key = PyUnicode_AsWideCharString(args[1], NULL);
1420 if (sub_key == NULL) {
1421 goto exit;
1422 }
1423 }
1424 else {
1425 _PyArg_BadArgument("SetValue", "argument 2", "str or None", args[1]);
1426 goto exit;
1427 }
1428 if (!_PyLong_UnsignedLong_Converter(args[2], &type)) {
1429 goto exit;
1430 }
1431 if (!PyUnicode_Check(args[3])) {
1432 _PyArg_BadArgument("SetValue", "argument 4", "str", args[3]);
1433 goto exit;
1434 }
1435 value_obj = args[3];
1436 return_value = winreg_SetValue_impl(module, key, sub_key, type, value_obj);
1437
1438 exit:
1439 /* Cleanup for sub_key */
1440 PyMem_Free((void *)sub_key);
1441
1442 return return_value;
1443 }
1444
1445 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
1446
1447 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
1448
1449 PyDoc_STRVAR(winreg_SetValueEx__doc__,
1450 "SetValueEx($module, key, value_name, reserved, type, value, /)\n"
1451 "--\n"
1452 "\n"
1453 "Stores data in the value field of an open registry key.\n"
1454 "\n"
1455 " key\n"
1456 " An already open key, or any one of the predefined HKEY_* constants.\n"
1457 " value_name\n"
1458 " A string containing the name of the value to set, or None.\n"
1459 " reserved\n"
1460 " Can be anything - zero is always passed to the API.\n"
1461 " type\n"
1462 " An integer that specifies the type of the data, one of:\n"
1463 " REG_BINARY -- Binary data in any form.\n"
1464 " REG_DWORD -- A 32-bit number.\n"
1465 " REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format. Equivalent to REG_DWORD\n"
1466 " REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.\n"
1467 " REG_EXPAND_SZ -- A null-terminated string that contains unexpanded\n"
1468 " references to environment variables (for example,\n"
1469 " %PATH%).\n"
1470 " REG_LINK -- A Unicode symbolic link.\n"
1471 " REG_MULTI_SZ -- A sequence of null-terminated strings, terminated\n"
1472 " by two null characters. Note that Python handles\n"
1473 " this termination automatically.\n"
1474 " REG_NONE -- No defined value type.\n"
1475 " REG_QWORD -- A 64-bit number.\n"
1476 " REG_QWORD_LITTLE_ENDIAN -- A 64-bit number in little-endian format. Equivalent to REG_QWORD.\n"
1477 " REG_RESOURCE_LIST -- A device-driver resource list.\n"
1478 " REG_SZ -- A null-terminated string.\n"
1479 " value\n"
1480 " A string that specifies the new value.\n"
1481 "\n"
1482 "This method can also set additional value and type information for the\n"
1483 "specified key. The key identified by the key parameter must have been\n"
1484 "opened with KEY_SET_VALUE access.\n"
1485 "\n"
1486 "To open the key, use the CreateKeyEx() or OpenKeyEx() methods.\n"
1487 "\n"
1488 "Value lengths are limited by available memory. Long values (more than\n"
1489 "2048 bytes) should be stored as files with the filenames stored in\n"
1490 "the configuration registry to help the registry perform efficiently.");
1491
1492 #define WINREG_SETVALUEEX_METHODDEF \
1493 {"SetValueEx", _PyCFunction_CAST(winreg_SetValueEx), METH_FASTCALL, winreg_SetValueEx__doc__},
1494
1495 static PyObject *
1496 winreg_SetValueEx_impl(PyObject *module, HKEY key, const wchar_t *value_name,
1497 PyObject *reserved, DWORD type, PyObject *value);
1498
1499 static PyObject *
winreg_SetValueEx(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1500 winreg_SetValueEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1501 {
1502 PyObject *return_value = NULL;
1503 HKEY key;
1504 const wchar_t *value_name = NULL;
1505 PyObject *reserved;
1506 DWORD type;
1507 PyObject *value;
1508
1509 if (!_PyArg_CheckPositional("SetValueEx", nargs, 5, 5)) {
1510 goto exit;
1511 }
1512 if (!clinic_HKEY_converter(_PyModule_GetState(module), args[0], &key)) {
1513 goto exit;
1514 }
1515 if (args[1] == Py_None) {
1516 value_name = NULL;
1517 }
1518 else if (PyUnicode_Check(args[1])) {
1519 value_name = PyUnicode_AsWideCharString(args[1], NULL);
1520 if (value_name == NULL) {
1521 goto exit;
1522 }
1523 }
1524 else {
1525 _PyArg_BadArgument("SetValueEx", "argument 2", "str or None", args[1]);
1526 goto exit;
1527 }
1528 reserved = args[2];
1529 if (!_PyLong_UnsignedLong_Converter(args[3], &type)) {
1530 goto exit;
1531 }
1532 value = args[4];
1533 return_value = winreg_SetValueEx_impl(module, key, value_name, reserved, type, value);
1534
1535 exit:
1536 /* Cleanup for value_name */
1537 PyMem_Free((void *)value_name);
1538
1539 return return_value;
1540 }
1541
1542 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
1543
1544 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
1545
1546 PyDoc_STRVAR(winreg_DisableReflectionKey__doc__,
1547 "DisableReflectionKey($module, key, /)\n"
1548 "--\n"
1549 "\n"
1550 "Disables registry reflection for 32bit processes running on a 64bit OS.\n"
1551 "\n"
1552 " key\n"
1553 " An already open key, or any one of the predefined HKEY_* constants.\n"
1554 "\n"
1555 "Will generally raise NotImplementedError if executed on a 32bit OS.\n"
1556 "\n"
1557 "If the key is not on the reflection list, the function succeeds but has\n"
1558 "no effect. Disabling reflection for a key does not affect reflection\n"
1559 "of any subkeys.");
1560
1561 #define WINREG_DISABLEREFLECTIONKEY_METHODDEF \
1562 {"DisableReflectionKey", (PyCFunction)winreg_DisableReflectionKey, METH_O, winreg_DisableReflectionKey__doc__},
1563
1564 static PyObject *
1565 winreg_DisableReflectionKey_impl(PyObject *module, HKEY key);
1566
1567 static PyObject *
winreg_DisableReflectionKey(PyObject * module,PyObject * arg)1568 winreg_DisableReflectionKey(PyObject *module, PyObject *arg)
1569 {
1570 PyObject *return_value = NULL;
1571 HKEY key;
1572
1573 if (!clinic_HKEY_converter(_PyModule_GetState(module), arg, &key)) {
1574 goto exit;
1575 }
1576 return_value = winreg_DisableReflectionKey_impl(module, key);
1577
1578 exit:
1579 return return_value;
1580 }
1581
1582 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
1583
1584 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
1585
1586 PyDoc_STRVAR(winreg_EnableReflectionKey__doc__,
1587 "EnableReflectionKey($module, key, /)\n"
1588 "--\n"
1589 "\n"
1590 "Restores registry reflection for the specified disabled key.\n"
1591 "\n"
1592 " key\n"
1593 " An already open key, or any one of the predefined HKEY_* constants.\n"
1594 "\n"
1595 "Will generally raise NotImplementedError if executed on a 32bit OS.\n"
1596 "Restoring reflection for a key does not affect reflection of any\n"
1597 "subkeys.");
1598
1599 #define WINREG_ENABLEREFLECTIONKEY_METHODDEF \
1600 {"EnableReflectionKey", (PyCFunction)winreg_EnableReflectionKey, METH_O, winreg_EnableReflectionKey__doc__},
1601
1602 static PyObject *
1603 winreg_EnableReflectionKey_impl(PyObject *module, HKEY key);
1604
1605 static PyObject *
winreg_EnableReflectionKey(PyObject * module,PyObject * arg)1606 winreg_EnableReflectionKey(PyObject *module, PyObject *arg)
1607 {
1608 PyObject *return_value = NULL;
1609 HKEY key;
1610
1611 if (!clinic_HKEY_converter(_PyModule_GetState(module), arg, &key)) {
1612 goto exit;
1613 }
1614 return_value = winreg_EnableReflectionKey_impl(module, key);
1615
1616 exit:
1617 return return_value;
1618 }
1619
1620 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
1621
1622 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
1623
1624 PyDoc_STRVAR(winreg_QueryReflectionKey__doc__,
1625 "QueryReflectionKey($module, key, /)\n"
1626 "--\n"
1627 "\n"
1628 "Returns the reflection state for the specified key as a bool.\n"
1629 "\n"
1630 " key\n"
1631 " An already open key, or any one of the predefined HKEY_* constants.\n"
1632 "\n"
1633 "Will generally raise NotImplementedError if executed on a 32bit OS.");
1634
1635 #define WINREG_QUERYREFLECTIONKEY_METHODDEF \
1636 {"QueryReflectionKey", (PyCFunction)winreg_QueryReflectionKey, METH_O, winreg_QueryReflectionKey__doc__},
1637
1638 static PyObject *
1639 winreg_QueryReflectionKey_impl(PyObject *module, HKEY key);
1640
1641 static PyObject *
winreg_QueryReflectionKey(PyObject * module,PyObject * arg)1642 winreg_QueryReflectionKey(PyObject *module, PyObject *arg)
1643 {
1644 PyObject *return_value = NULL;
1645 HKEY key;
1646
1647 if (!clinic_HKEY_converter(_PyModule_GetState(module), arg, &key)) {
1648 goto exit;
1649 }
1650 return_value = winreg_QueryReflectionKey_impl(module, key);
1651
1652 exit:
1653 return return_value;
1654 }
1655
1656 #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) && (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
1657
1658 #ifndef WINREG_HKEYTYPE_CLOSE_METHODDEF
1659 #define WINREG_HKEYTYPE_CLOSE_METHODDEF
1660 #endif /* !defined(WINREG_HKEYTYPE_CLOSE_METHODDEF) */
1661
1662 #ifndef WINREG_HKEYTYPE_DETACH_METHODDEF
1663 #define WINREG_HKEYTYPE_DETACH_METHODDEF
1664 #endif /* !defined(WINREG_HKEYTYPE_DETACH_METHODDEF) */
1665
1666 #ifndef WINREG_HKEYTYPE___ENTER___METHODDEF
1667 #define WINREG_HKEYTYPE___ENTER___METHODDEF
1668 #endif /* !defined(WINREG_HKEYTYPE___ENTER___METHODDEF) */
1669
1670 #ifndef WINREG_HKEYTYPE___EXIT___METHODDEF
1671 #define WINREG_HKEYTYPE___EXIT___METHODDEF
1672 #endif /* !defined(WINREG_HKEYTYPE___EXIT___METHODDEF) */
1673
1674 #ifndef WINREG_CLOSEKEY_METHODDEF
1675 #define WINREG_CLOSEKEY_METHODDEF
1676 #endif /* !defined(WINREG_CLOSEKEY_METHODDEF) */
1677
1678 #ifndef WINREG_CONNECTREGISTRY_METHODDEF
1679 #define WINREG_CONNECTREGISTRY_METHODDEF
1680 #endif /* !defined(WINREG_CONNECTREGISTRY_METHODDEF) */
1681
1682 #ifndef WINREG_CREATEKEY_METHODDEF
1683 #define WINREG_CREATEKEY_METHODDEF
1684 #endif /* !defined(WINREG_CREATEKEY_METHODDEF) */
1685
1686 #ifndef WINREG_CREATEKEYEX_METHODDEF
1687 #define WINREG_CREATEKEYEX_METHODDEF
1688 #endif /* !defined(WINREG_CREATEKEYEX_METHODDEF) */
1689
1690 #ifndef WINREG_DELETEKEY_METHODDEF
1691 #define WINREG_DELETEKEY_METHODDEF
1692 #endif /* !defined(WINREG_DELETEKEY_METHODDEF) */
1693
1694 #ifndef WINREG_DELETEKEYEX_METHODDEF
1695 #define WINREG_DELETEKEYEX_METHODDEF
1696 #endif /* !defined(WINREG_DELETEKEYEX_METHODDEF) */
1697
1698 #ifndef WINREG_DELETEVALUE_METHODDEF
1699 #define WINREG_DELETEVALUE_METHODDEF
1700 #endif /* !defined(WINREG_DELETEVALUE_METHODDEF) */
1701
1702 #ifndef WINREG_ENUMKEY_METHODDEF
1703 #define WINREG_ENUMKEY_METHODDEF
1704 #endif /* !defined(WINREG_ENUMKEY_METHODDEF) */
1705
1706 #ifndef WINREG_ENUMVALUE_METHODDEF
1707 #define WINREG_ENUMVALUE_METHODDEF
1708 #endif /* !defined(WINREG_ENUMVALUE_METHODDEF) */
1709
1710 #ifndef WINREG_EXPANDENVIRONMENTSTRINGS_METHODDEF
1711 #define WINREG_EXPANDENVIRONMENTSTRINGS_METHODDEF
1712 #endif /* !defined(WINREG_EXPANDENVIRONMENTSTRINGS_METHODDEF) */
1713
1714 #ifndef WINREG_FLUSHKEY_METHODDEF
1715 #define WINREG_FLUSHKEY_METHODDEF
1716 #endif /* !defined(WINREG_FLUSHKEY_METHODDEF) */
1717
1718 #ifndef WINREG_LOADKEY_METHODDEF
1719 #define WINREG_LOADKEY_METHODDEF
1720 #endif /* !defined(WINREG_LOADKEY_METHODDEF) */
1721
1722 #ifndef WINREG_OPENKEY_METHODDEF
1723 #define WINREG_OPENKEY_METHODDEF
1724 #endif /* !defined(WINREG_OPENKEY_METHODDEF) */
1725
1726 #ifndef WINREG_OPENKEYEX_METHODDEF
1727 #define WINREG_OPENKEYEX_METHODDEF
1728 #endif /* !defined(WINREG_OPENKEYEX_METHODDEF) */
1729
1730 #ifndef WINREG_QUERYINFOKEY_METHODDEF
1731 #define WINREG_QUERYINFOKEY_METHODDEF
1732 #endif /* !defined(WINREG_QUERYINFOKEY_METHODDEF) */
1733
1734 #ifndef WINREG_QUERYVALUE_METHODDEF
1735 #define WINREG_QUERYVALUE_METHODDEF
1736 #endif /* !defined(WINREG_QUERYVALUE_METHODDEF) */
1737
1738 #ifndef WINREG_QUERYVALUEEX_METHODDEF
1739 #define WINREG_QUERYVALUEEX_METHODDEF
1740 #endif /* !defined(WINREG_QUERYVALUEEX_METHODDEF) */
1741
1742 #ifndef WINREG_SAVEKEY_METHODDEF
1743 #define WINREG_SAVEKEY_METHODDEF
1744 #endif /* !defined(WINREG_SAVEKEY_METHODDEF) */
1745
1746 #ifndef WINREG_SETVALUE_METHODDEF
1747 #define WINREG_SETVALUE_METHODDEF
1748 #endif /* !defined(WINREG_SETVALUE_METHODDEF) */
1749
1750 #ifndef WINREG_SETVALUEEX_METHODDEF
1751 #define WINREG_SETVALUEEX_METHODDEF
1752 #endif /* !defined(WINREG_SETVALUEEX_METHODDEF) */
1753
1754 #ifndef WINREG_DISABLEREFLECTIONKEY_METHODDEF
1755 #define WINREG_DISABLEREFLECTIONKEY_METHODDEF
1756 #endif /* !defined(WINREG_DISABLEREFLECTIONKEY_METHODDEF) */
1757
1758 #ifndef WINREG_ENABLEREFLECTIONKEY_METHODDEF
1759 #define WINREG_ENABLEREFLECTIONKEY_METHODDEF
1760 #endif /* !defined(WINREG_ENABLEREFLECTIONKEY_METHODDEF) */
1761
1762 #ifndef WINREG_QUERYREFLECTIONKEY_METHODDEF
1763 #define WINREG_QUERYREFLECTIONKEY_METHODDEF
1764 #endif /* !defined(WINREG_QUERYREFLECTIONKEY_METHODDEF) */
1765 /*[clinic end generated code: output=1ee4098b2f143b6a input=a9049054013a1b77]*/
1766