Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(winreg_HKEYType_Close__doc__, |
| 6 | "Close($self, /)\n" |
| 7 | "--\n" |
| 8 | "\n" |
| 9 | "Closes the underlying Windows handle.\n" |
| 10 | "\n" |
| 11 | "If the handle is already closed, no error is raised."); |
| 12 | |
| 13 | #define WINREG_HKEYTYPE_CLOSE_METHODDEF \ |
| 14 | {"Close", (PyCFunction)winreg_HKEYType_Close, METH_NOARGS, winreg_HKEYType_Close__doc__}, |
| 15 | |
| 16 | static PyObject * |
| 17 | winreg_HKEYType_Close_impl(PyHKEYObject *self); |
| 18 | |
| 19 | static PyObject * |
| 20 | winreg_HKEYType_Close(PyHKEYObject *self, PyObject *Py_UNUSED(ignored)) |
| 21 | { |
| 22 | return winreg_HKEYType_Close_impl(self); |
| 23 | } |
| 24 | |
| 25 | PyDoc_STRVAR(winreg_HKEYType_Detach__doc__, |
| 26 | "Detach($self, /)\n" |
| 27 | "--\n" |
| 28 | "\n" |
| 29 | "Detaches the Windows handle from the handle object.\n" |
| 30 | "\n" |
| 31 | "The result is the value of the handle before it is detached. If the\n" |
| 32 | "handle is already detached, this will return zero.\n" |
| 33 | "\n" |
| 34 | "After calling this function, the handle is effectively invalidated,\n" |
| 35 | "but the handle is not closed. You would call this function when you\n" |
| 36 | "need the underlying win32 handle to exist beyond the lifetime of the\n" |
| 37 | "handle object."); |
| 38 | |
| 39 | #define WINREG_HKEYTYPE_DETACH_METHODDEF \ |
| 40 | {"Detach", (PyCFunction)winreg_HKEYType_Detach, METH_NOARGS, winreg_HKEYType_Detach__doc__}, |
| 41 | |
| 42 | static PyObject * |
| 43 | winreg_HKEYType_Detach_impl(PyHKEYObject *self); |
| 44 | |
| 45 | static PyObject * |
| 46 | winreg_HKEYType_Detach(PyHKEYObject *self, PyObject *Py_UNUSED(ignored)) |
| 47 | { |
| 48 | return winreg_HKEYType_Detach_impl(self); |
| 49 | } |
| 50 | |
| 51 | PyDoc_STRVAR(winreg_HKEYType___enter____doc__, |
| 52 | "__enter__($self, /)\n" |
| 53 | "--\n" |
| 54 | "\n"); |
| 55 | |
| 56 | #define WINREG_HKEYTYPE___ENTER___METHODDEF \ |
| 57 | {"__enter__", (PyCFunction)winreg_HKEYType___enter__, METH_NOARGS, winreg_HKEYType___enter____doc__}, |
| 58 | |
| 59 | static PyHKEYObject * |
| 60 | winreg_HKEYType___enter___impl(PyHKEYObject *self); |
| 61 | |
| 62 | static PyObject * |
| 63 | winreg_HKEYType___enter__(PyHKEYObject *self, PyObject *Py_UNUSED(ignored)) |
| 64 | { |
| 65 | PyObject *return_value = NULL; |
| 66 | PyHKEYObject *_return_value; |
| 67 | |
| 68 | _return_value = winreg_HKEYType___enter___impl(self); |
| 69 | return_value = (PyObject *)_return_value; |
| 70 | |
| 71 | return return_value; |
| 72 | } |
| 73 | |
| 74 | PyDoc_STRVAR(winreg_HKEYType___exit____doc__, |
| 75 | "__exit__($self, /, exc_type, exc_value, traceback)\n" |
| 76 | "--\n" |
| 77 | "\n"); |
| 78 | |
| 79 | #define WINREG_HKEYTYPE___EXIT___METHODDEF \ |
| 80 | {"__exit__", (PyCFunction)winreg_HKEYType___exit__, METH_VARARGS|METH_KEYWORDS, winreg_HKEYType___exit____doc__}, |
| 81 | |
| 82 | static PyObject * |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 83 | winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type, |
| 84 | PyObject *exc_value, PyObject *traceback); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 85 | |
| 86 | static PyObject * |
| 87 | winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *args, PyObject *kwargs) |
| 88 | { |
| 89 | PyObject *return_value = NULL; |
| 90 | static char *_keywords[] = {"exc_type", "exc_value", "traceback", NULL}; |
| 91 | PyObject *exc_type; |
| 92 | PyObject *exc_value; |
| 93 | PyObject *traceback; |
| 94 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 95 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:__exit__", _keywords, |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 96 | &exc_type, &exc_value, &traceback)) |
| 97 | goto exit; |
| 98 | return_value = winreg_HKEYType___exit___impl(self, exc_type, exc_value, traceback); |
| 99 | |
| 100 | exit: |
| 101 | return return_value; |
| 102 | } |
| 103 | |
| 104 | PyDoc_STRVAR(winreg_CloseKey__doc__, |
| 105 | "CloseKey($module, hkey, /)\n" |
| 106 | "--\n" |
| 107 | "\n" |
| 108 | "Closes a previously opened registry key.\n" |
| 109 | "\n" |
| 110 | " hkey\n" |
| 111 | " A previously opened key.\n" |
| 112 | "\n" |
| 113 | "Note that if the key is not closed using this method, it will be\n" |
| 114 | "closed when the hkey object is destroyed by Python."); |
| 115 | |
| 116 | #define WINREG_CLOSEKEY_METHODDEF \ |
| 117 | {"CloseKey", (PyCFunction)winreg_CloseKey, METH_O, winreg_CloseKey__doc__}, |
| 118 | |
| 119 | PyDoc_STRVAR(winreg_ConnectRegistry__doc__, |
| 120 | "ConnectRegistry($module, computer_name, key, /)\n" |
| 121 | "--\n" |
| 122 | "\n" |
Serhiy Storchaka | 6a7b3a7 | 2016-04-17 08:32:47 +0300 | [diff] [blame^] | 123 | "Establishes a connection to the registry on another computer.\n" |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 124 | "\n" |
| 125 | " computer_name\n" |
| 126 | " The name of the remote computer, of the form r\"\\\\computername\". If\n" |
| 127 | " None, the local computer is used.\n" |
| 128 | " key\n" |
| 129 | " The predefined key to connect to.\n" |
| 130 | "\n" |
| 131 | "The return value is the handle of the opened key.\n" |
| 132 | "If the function fails, an OSError exception is raised."); |
| 133 | |
| 134 | #define WINREG_CONNECTREGISTRY_METHODDEF \ |
| 135 | {"ConnectRegistry", (PyCFunction)winreg_ConnectRegistry, METH_VARARGS, winreg_ConnectRegistry__doc__}, |
| 136 | |
| 137 | static HKEY |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 138 | winreg_ConnectRegistry_impl(PyModuleDef *module, Py_UNICODE *computer_name, |
| 139 | HKEY key); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 140 | |
| 141 | static PyObject * |
| 142 | winreg_ConnectRegistry(PyModuleDef *module, PyObject *args) |
| 143 | { |
| 144 | PyObject *return_value = NULL; |
| 145 | Py_UNICODE *computer_name; |
| 146 | HKEY key; |
| 147 | HKEY _return_value; |
| 148 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 149 | if (!PyArg_ParseTuple(args, "ZO&:ConnectRegistry", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 150 | &computer_name, clinic_HKEY_converter, &key)) |
| 151 | goto exit; |
| 152 | _return_value = winreg_ConnectRegistry_impl(module, computer_name, key); |
| 153 | if (_return_value == NULL) |
| 154 | goto exit; |
| 155 | return_value = PyHKEY_FromHKEY(_return_value); |
| 156 | |
| 157 | exit: |
| 158 | return return_value; |
| 159 | } |
| 160 | |
| 161 | PyDoc_STRVAR(winreg_CreateKey__doc__, |
| 162 | "CreateKey($module, key, sub_key, /)\n" |
| 163 | "--\n" |
| 164 | "\n" |
| 165 | "Creates or opens the specified key.\n" |
| 166 | "\n" |
| 167 | " key\n" |
| 168 | " An already open key, or one of the predefined HKEY_* constants.\n" |
| 169 | " sub_key\n" |
| 170 | " The name of the key this method opens or creates.\n" |
| 171 | "\n" |
| 172 | "If key is one of the predefined keys, sub_key may be None. In that case,\n" |
| 173 | "the handle returned is the same key handle passed in to the function.\n" |
| 174 | "\n" |
| 175 | "If the key already exists, this function opens the existing key.\n" |
| 176 | "\n" |
| 177 | "The return value is the handle of the opened key.\n" |
| 178 | "If the function fails, an OSError exception is raised."); |
| 179 | |
| 180 | #define WINREG_CREATEKEY_METHODDEF \ |
| 181 | {"CreateKey", (PyCFunction)winreg_CreateKey, METH_VARARGS, winreg_CreateKey__doc__}, |
| 182 | |
| 183 | static HKEY |
| 184 | winreg_CreateKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key); |
| 185 | |
| 186 | static PyObject * |
| 187 | winreg_CreateKey(PyModuleDef *module, PyObject *args) |
| 188 | { |
| 189 | PyObject *return_value = NULL; |
| 190 | HKEY key; |
| 191 | Py_UNICODE *sub_key; |
| 192 | HKEY _return_value; |
| 193 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 194 | if (!PyArg_ParseTuple(args, "O&Z:CreateKey", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 195 | clinic_HKEY_converter, &key, &sub_key)) |
| 196 | goto exit; |
| 197 | _return_value = winreg_CreateKey_impl(module, key, sub_key); |
| 198 | if (_return_value == NULL) |
| 199 | goto exit; |
| 200 | return_value = PyHKEY_FromHKEY(_return_value); |
| 201 | |
| 202 | exit: |
| 203 | return return_value; |
| 204 | } |
| 205 | |
| 206 | PyDoc_STRVAR(winreg_CreateKeyEx__doc__, |
| 207 | "CreateKeyEx($module, /, key, sub_key, reserved=0,\n" |
| 208 | " access=winreg.KEY_WRITE)\n" |
| 209 | "--\n" |
| 210 | "\n" |
| 211 | "Creates or opens the specified key.\n" |
| 212 | "\n" |
| 213 | " key\n" |
| 214 | " An already open key, or one of the predefined HKEY_* constants.\n" |
| 215 | " sub_key\n" |
| 216 | " The name of the key this method opens or creates.\n" |
| 217 | " reserved\n" |
| 218 | " A reserved integer, and must be zero. Default is zero.\n" |
| 219 | " access\n" |
| 220 | " An integer that specifies an access mask that describes the\n" |
| 221 | " desired security access for the key. Default is KEY_WRITE.\n" |
| 222 | "\n" |
| 223 | "If key is one of the predefined keys, sub_key may be None. In that case,\n" |
| 224 | "the handle returned is the same key handle passed in to the function.\n" |
| 225 | "\n" |
| 226 | "If the key already exists, this function opens the existing key\n" |
| 227 | "\n" |
| 228 | "The return value is the handle of the opened key.\n" |
| 229 | "If the function fails, an OSError exception is raised."); |
| 230 | |
| 231 | #define WINREG_CREATEKEYEX_METHODDEF \ |
| 232 | {"CreateKeyEx", (PyCFunction)winreg_CreateKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_CreateKeyEx__doc__}, |
| 233 | |
| 234 | static HKEY |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 235 | winreg_CreateKeyEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, |
| 236 | int reserved, REGSAM access); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 237 | |
| 238 | static PyObject * |
| 239 | winreg_CreateKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) |
| 240 | { |
| 241 | PyObject *return_value = NULL; |
| 242 | static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; |
| 243 | HKEY key; |
| 244 | Py_UNICODE *sub_key; |
| 245 | int reserved = 0; |
| 246 | REGSAM access = KEY_WRITE; |
| 247 | HKEY _return_value; |
| 248 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 249 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:CreateKeyEx", _keywords, |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 250 | clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) |
| 251 | goto exit; |
| 252 | _return_value = winreg_CreateKeyEx_impl(module, key, sub_key, reserved, access); |
| 253 | if (_return_value == NULL) |
| 254 | goto exit; |
| 255 | return_value = PyHKEY_FromHKEY(_return_value); |
| 256 | |
| 257 | exit: |
| 258 | return return_value; |
| 259 | } |
| 260 | |
| 261 | PyDoc_STRVAR(winreg_DeleteKey__doc__, |
| 262 | "DeleteKey($module, key, sub_key, /)\n" |
| 263 | "--\n" |
| 264 | "\n" |
| 265 | "Deletes the specified key.\n" |
| 266 | "\n" |
| 267 | " key\n" |
| 268 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 269 | " sub_key\n" |
| 270 | " A string that must be the name of a subkey of the key identified by\n" |
| 271 | " the key parameter. This value must not be None, and the key may not\n" |
| 272 | " have subkeys.\n" |
| 273 | "\n" |
| 274 | "This method can not delete keys with subkeys.\n" |
| 275 | "\n" |
| 276 | "If the function succeeds, the entire key, including all of its values,\n" |
| 277 | "is removed. If the function fails, an OSError exception is raised."); |
| 278 | |
| 279 | #define WINREG_DELETEKEY_METHODDEF \ |
| 280 | {"DeleteKey", (PyCFunction)winreg_DeleteKey, METH_VARARGS, winreg_DeleteKey__doc__}, |
| 281 | |
| 282 | static PyObject * |
| 283 | winreg_DeleteKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key); |
| 284 | |
| 285 | static PyObject * |
| 286 | winreg_DeleteKey(PyModuleDef *module, PyObject *args) |
| 287 | { |
| 288 | PyObject *return_value = NULL; |
| 289 | HKEY key; |
| 290 | Py_UNICODE *sub_key; |
| 291 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 292 | if (!PyArg_ParseTuple(args, "O&u:DeleteKey", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 293 | clinic_HKEY_converter, &key, &sub_key)) |
| 294 | goto exit; |
| 295 | return_value = winreg_DeleteKey_impl(module, key, sub_key); |
| 296 | |
| 297 | exit: |
| 298 | return return_value; |
| 299 | } |
| 300 | |
| 301 | PyDoc_STRVAR(winreg_DeleteKeyEx__doc__, |
| 302 | "DeleteKeyEx($module, /, key, sub_key, access=winreg.KEY_WOW64_64KEY,\n" |
| 303 | " reserved=0)\n" |
| 304 | "--\n" |
| 305 | "\n" |
| 306 | "Deletes the specified key (64-bit OS only).\n" |
| 307 | "\n" |
| 308 | " key\n" |
| 309 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 310 | " sub_key\n" |
| 311 | " A string that must be the name of a subkey of the key identified by\n" |
| 312 | " the key parameter. This value must not be None, and the key may not\n" |
| 313 | " have subkeys.\n" |
| 314 | " access\n" |
| 315 | " An integer that specifies an access mask that describes the\n" |
| 316 | " desired security access for the key. Default is KEY_WOW64_64KEY.\n" |
| 317 | " reserved\n" |
| 318 | " A reserved integer, and must be zero. Default is zero.\n" |
| 319 | "\n" |
| 320 | "This method can not delete keys with subkeys.\n" |
| 321 | "\n" |
| 322 | "If the function succeeds, the entire key, including all of its values,\n" |
| 323 | "is removed. If the function fails, an OSError exception is raised.\n" |
| 324 | "On unsupported Windows versions, NotImplementedError is raised."); |
| 325 | |
| 326 | #define WINREG_DELETEKEYEX_METHODDEF \ |
| 327 | {"DeleteKeyEx", (PyCFunction)winreg_DeleteKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_DeleteKeyEx__doc__}, |
| 328 | |
| 329 | static PyObject * |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 330 | winreg_DeleteKeyEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, |
| 331 | REGSAM access, int reserved); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 332 | |
| 333 | static PyObject * |
| 334 | winreg_DeleteKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) |
| 335 | { |
| 336 | PyObject *return_value = NULL; |
| 337 | static char *_keywords[] = {"key", "sub_key", "access", "reserved", NULL}; |
| 338 | HKEY key; |
| 339 | Py_UNICODE *sub_key; |
| 340 | REGSAM access = KEY_WOW64_64KEY; |
| 341 | int reserved = 0; |
| 342 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 343 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&u|ii:DeleteKeyEx", _keywords, |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 344 | clinic_HKEY_converter, &key, &sub_key, &access, &reserved)) |
| 345 | goto exit; |
| 346 | return_value = winreg_DeleteKeyEx_impl(module, key, sub_key, access, reserved); |
| 347 | |
| 348 | exit: |
| 349 | return return_value; |
| 350 | } |
| 351 | |
| 352 | PyDoc_STRVAR(winreg_DeleteValue__doc__, |
| 353 | "DeleteValue($module, key, value, /)\n" |
| 354 | "--\n" |
| 355 | "\n" |
| 356 | "Removes a named value from a registry key.\n" |
| 357 | "\n" |
| 358 | " key\n" |
| 359 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 360 | " value\n" |
| 361 | " A string that identifies the value to remove."); |
| 362 | |
| 363 | #define WINREG_DELETEVALUE_METHODDEF \ |
| 364 | {"DeleteValue", (PyCFunction)winreg_DeleteValue, METH_VARARGS, winreg_DeleteValue__doc__}, |
| 365 | |
| 366 | static PyObject * |
| 367 | winreg_DeleteValue_impl(PyModuleDef *module, HKEY key, Py_UNICODE *value); |
| 368 | |
| 369 | static PyObject * |
| 370 | winreg_DeleteValue(PyModuleDef *module, PyObject *args) |
| 371 | { |
| 372 | PyObject *return_value = NULL; |
| 373 | HKEY key; |
| 374 | Py_UNICODE *value; |
| 375 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 376 | if (!PyArg_ParseTuple(args, "O&Z:DeleteValue", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 377 | clinic_HKEY_converter, &key, &value)) |
| 378 | goto exit; |
| 379 | return_value = winreg_DeleteValue_impl(module, key, value); |
| 380 | |
| 381 | exit: |
| 382 | return return_value; |
| 383 | } |
| 384 | |
| 385 | PyDoc_STRVAR(winreg_EnumKey__doc__, |
| 386 | "EnumKey($module, key, index, /)\n" |
| 387 | "--\n" |
| 388 | "\n" |
| 389 | "Enumerates subkeys of an open registry key.\n" |
| 390 | "\n" |
| 391 | " key\n" |
| 392 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 393 | " index\n" |
| 394 | " An integer that identifies the index of the key to retrieve.\n" |
| 395 | "\n" |
| 396 | "The function retrieves the name of one subkey each time it is called.\n" |
| 397 | "It is typically called repeatedly until an OSError exception is\n" |
| 398 | "raised, indicating no more values are available."); |
| 399 | |
| 400 | #define WINREG_ENUMKEY_METHODDEF \ |
| 401 | {"EnumKey", (PyCFunction)winreg_EnumKey, METH_VARARGS, winreg_EnumKey__doc__}, |
| 402 | |
| 403 | static PyObject * |
| 404 | winreg_EnumKey_impl(PyModuleDef *module, HKEY key, int index); |
| 405 | |
| 406 | static PyObject * |
| 407 | winreg_EnumKey(PyModuleDef *module, PyObject *args) |
| 408 | { |
| 409 | PyObject *return_value = NULL; |
| 410 | HKEY key; |
| 411 | int index; |
| 412 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 413 | if (!PyArg_ParseTuple(args, "O&i:EnumKey", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 414 | clinic_HKEY_converter, &key, &index)) |
| 415 | goto exit; |
| 416 | return_value = winreg_EnumKey_impl(module, key, index); |
| 417 | |
| 418 | exit: |
| 419 | return return_value; |
| 420 | } |
| 421 | |
| 422 | PyDoc_STRVAR(winreg_EnumValue__doc__, |
| 423 | "EnumValue($module, key, index, /)\n" |
| 424 | "--\n" |
| 425 | "\n" |
| 426 | "Enumerates values of an open registry key.\n" |
| 427 | "\n" |
| 428 | " key\n" |
| 429 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 430 | " index\n" |
| 431 | " An integer that identifies the index of the value to retrieve.\n" |
| 432 | "\n" |
| 433 | "The function retrieves the name of one subkey each time it is called.\n" |
| 434 | "It is typically called repeatedly, until an OSError exception\n" |
| 435 | "is raised, indicating no more values.\n" |
| 436 | "\n" |
| 437 | "The result is a tuple of 3 items:\n" |
| 438 | " value_name\n" |
| 439 | " A string that identifies the value.\n" |
| 440 | " value_data\n" |
| 441 | " An object that holds the value data, and whose type depends\n" |
| 442 | " on the underlying registry type.\n" |
| 443 | " data_type\n" |
| 444 | " An integer that identifies the type of the value data."); |
| 445 | |
| 446 | #define WINREG_ENUMVALUE_METHODDEF \ |
| 447 | {"EnumValue", (PyCFunction)winreg_EnumValue, METH_VARARGS, winreg_EnumValue__doc__}, |
| 448 | |
| 449 | static PyObject * |
| 450 | winreg_EnumValue_impl(PyModuleDef *module, HKEY key, int index); |
| 451 | |
| 452 | static PyObject * |
| 453 | winreg_EnumValue(PyModuleDef *module, PyObject *args) |
| 454 | { |
| 455 | PyObject *return_value = NULL; |
| 456 | HKEY key; |
| 457 | int index; |
| 458 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 459 | if (!PyArg_ParseTuple(args, "O&i:EnumValue", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 460 | clinic_HKEY_converter, &key, &index)) |
| 461 | goto exit; |
| 462 | return_value = winreg_EnumValue_impl(module, key, index); |
| 463 | |
| 464 | exit: |
| 465 | return return_value; |
| 466 | } |
| 467 | |
| 468 | PyDoc_STRVAR(winreg_ExpandEnvironmentStrings__doc__, |
| 469 | "ExpandEnvironmentStrings($module, string, /)\n" |
| 470 | "--\n" |
| 471 | "\n" |
| 472 | "Expand environment vars."); |
| 473 | |
| 474 | #define WINREG_EXPANDENVIRONMENTSTRINGS_METHODDEF \ |
| 475 | {"ExpandEnvironmentStrings", (PyCFunction)winreg_ExpandEnvironmentStrings, METH_O, winreg_ExpandEnvironmentStrings__doc__}, |
| 476 | |
| 477 | static PyObject * |
| 478 | winreg_ExpandEnvironmentStrings_impl(PyModuleDef *module, Py_UNICODE *string); |
| 479 | |
| 480 | static PyObject * |
| 481 | winreg_ExpandEnvironmentStrings(PyModuleDef *module, PyObject *arg) |
| 482 | { |
| 483 | PyObject *return_value = NULL; |
| 484 | Py_UNICODE *string; |
| 485 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 486 | if (!PyArg_Parse(arg, "u:ExpandEnvironmentStrings", &string)) |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 487 | goto exit; |
| 488 | return_value = winreg_ExpandEnvironmentStrings_impl(module, string); |
| 489 | |
| 490 | exit: |
| 491 | return return_value; |
| 492 | } |
| 493 | |
| 494 | PyDoc_STRVAR(winreg_FlushKey__doc__, |
| 495 | "FlushKey($module, key, /)\n" |
| 496 | "--\n" |
| 497 | "\n" |
| 498 | "Writes all the attributes of a key to the registry.\n" |
| 499 | "\n" |
| 500 | " key\n" |
| 501 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 502 | "\n" |
| 503 | "It is not necessary to call FlushKey to change a key. Registry changes\n" |
| 504 | "are flushed to disk by the registry using its lazy flusher. Registry\n" |
| 505 | "changes are also flushed to disk at system shutdown. Unlike\n" |
| 506 | "CloseKey(), the FlushKey() method returns only when all the data has\n" |
| 507 | "been written to the registry.\n" |
| 508 | "\n" |
| 509 | "An application should only call FlushKey() if it requires absolute\n" |
| 510 | "certainty that registry changes are on disk. If you don\'t know whether\n" |
| 511 | "a FlushKey() call is required, it probably isn\'t."); |
| 512 | |
| 513 | #define WINREG_FLUSHKEY_METHODDEF \ |
| 514 | {"FlushKey", (PyCFunction)winreg_FlushKey, METH_O, winreg_FlushKey__doc__}, |
| 515 | |
| 516 | static PyObject * |
| 517 | winreg_FlushKey_impl(PyModuleDef *module, HKEY key); |
| 518 | |
| 519 | static PyObject * |
| 520 | winreg_FlushKey(PyModuleDef *module, PyObject *arg) |
| 521 | { |
| 522 | PyObject *return_value = NULL; |
| 523 | HKEY key; |
| 524 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 525 | if (!PyArg_Parse(arg, "O&:FlushKey", clinic_HKEY_converter, &key)) |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 526 | goto exit; |
| 527 | return_value = winreg_FlushKey_impl(module, key); |
| 528 | |
| 529 | exit: |
| 530 | return return_value; |
| 531 | } |
| 532 | |
| 533 | PyDoc_STRVAR(winreg_LoadKey__doc__, |
| 534 | "LoadKey($module, key, sub_key, file_name, /)\n" |
| 535 | "--\n" |
| 536 | "\n" |
| 537 | "Insert data into the registry from a file.\n" |
| 538 | "\n" |
| 539 | " key\n" |
| 540 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 541 | " sub_key\n" |
| 542 | " A string that identifies the sub-key to load.\n" |
| 543 | " file_name\n" |
| 544 | " The name of the file to load registry data from. This file must\n" |
| 545 | " have been created with the SaveKey() function. Under the file\n" |
| 546 | " allocation table (FAT) file system, the filename may not have an\n" |
| 547 | " extension.\n" |
| 548 | "\n" |
| 549 | "Creates a subkey under the specified key and stores registration\n" |
| 550 | "information from a specified file into that subkey.\n" |
| 551 | "\n" |
| 552 | "A call to LoadKey() fails if the calling process does not have the\n" |
| 553 | "SE_RESTORE_PRIVILEGE privilege.\n" |
| 554 | "\n" |
| 555 | "If key is a handle returned by ConnectRegistry(), then the path\n" |
| 556 | "specified in fileName is relative to the remote computer.\n" |
| 557 | "\n" |
| 558 | "The MSDN docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE\n" |
| 559 | "tree."); |
| 560 | |
| 561 | #define WINREG_LOADKEY_METHODDEF \ |
| 562 | {"LoadKey", (PyCFunction)winreg_LoadKey, METH_VARARGS, winreg_LoadKey__doc__}, |
| 563 | |
| 564 | static PyObject * |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 565 | winreg_LoadKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, |
| 566 | Py_UNICODE *file_name); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 567 | |
| 568 | static PyObject * |
| 569 | winreg_LoadKey(PyModuleDef *module, PyObject *args) |
| 570 | { |
| 571 | PyObject *return_value = NULL; |
| 572 | HKEY key; |
| 573 | Py_UNICODE *sub_key; |
| 574 | Py_UNICODE *file_name; |
| 575 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 576 | if (!PyArg_ParseTuple(args, "O&uu:LoadKey", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 577 | clinic_HKEY_converter, &key, &sub_key, &file_name)) |
| 578 | goto exit; |
| 579 | return_value = winreg_LoadKey_impl(module, key, sub_key, file_name); |
| 580 | |
| 581 | exit: |
| 582 | return return_value; |
| 583 | } |
| 584 | |
| 585 | PyDoc_STRVAR(winreg_OpenKey__doc__, |
| 586 | "OpenKey($module, /, key, sub_key, reserved=0, access=winreg.KEY_READ)\n" |
| 587 | "--\n" |
| 588 | "\n" |
| 589 | "Opens the specified key.\n" |
| 590 | "\n" |
| 591 | " key\n" |
| 592 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 593 | " sub_key\n" |
| 594 | " A string that identifies the sub_key to open.\n" |
| 595 | " reserved\n" |
| 596 | " A reserved integer that must be zero. Default is zero.\n" |
| 597 | " access\n" |
| 598 | " An integer that specifies an access mask that describes the desired\n" |
| 599 | " security access for the key. Default is KEY_READ.\n" |
| 600 | "\n" |
| 601 | "The result is a new handle to the specified key.\n" |
| 602 | "If the function fails, an OSError exception is raised."); |
| 603 | |
| 604 | #define WINREG_OPENKEY_METHODDEF \ |
| 605 | {"OpenKey", (PyCFunction)winreg_OpenKey, METH_VARARGS|METH_KEYWORDS, winreg_OpenKey__doc__}, |
| 606 | |
| 607 | static HKEY |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 608 | winreg_OpenKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, |
| 609 | int reserved, REGSAM access); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 610 | |
| 611 | static PyObject * |
| 612 | winreg_OpenKey(PyModuleDef *module, PyObject *args, PyObject *kwargs) |
| 613 | { |
| 614 | PyObject *return_value = NULL; |
| 615 | static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; |
| 616 | HKEY key; |
| 617 | Py_UNICODE *sub_key; |
| 618 | int reserved = 0; |
| 619 | REGSAM access = KEY_READ; |
| 620 | HKEY _return_value; |
| 621 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 622 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKey", _keywords, |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 623 | clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) |
| 624 | goto exit; |
| 625 | _return_value = winreg_OpenKey_impl(module, key, sub_key, reserved, access); |
| 626 | if (_return_value == NULL) |
| 627 | goto exit; |
| 628 | return_value = PyHKEY_FromHKEY(_return_value); |
| 629 | |
| 630 | exit: |
| 631 | return return_value; |
| 632 | } |
| 633 | |
| 634 | PyDoc_STRVAR(winreg_OpenKeyEx__doc__, |
| 635 | "OpenKeyEx($module, /, key, sub_key, reserved=0, access=winreg.KEY_READ)\n" |
| 636 | "--\n" |
| 637 | "\n" |
| 638 | "Opens the specified key.\n" |
| 639 | "\n" |
| 640 | " key\n" |
| 641 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 642 | " sub_key\n" |
| 643 | " A string that identifies the sub_key to open.\n" |
| 644 | " reserved\n" |
| 645 | " A reserved integer that must be zero. Default is zero.\n" |
| 646 | " access\n" |
| 647 | " An integer that specifies an access mask that describes the desired\n" |
| 648 | " security access for the key. Default is KEY_READ.\n" |
| 649 | "\n" |
| 650 | "The result is a new handle to the specified key.\n" |
| 651 | "If the function fails, an OSError exception is raised."); |
| 652 | |
| 653 | #define WINREG_OPENKEYEX_METHODDEF \ |
| 654 | {"OpenKeyEx", (PyCFunction)winreg_OpenKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_OpenKeyEx__doc__}, |
| 655 | |
| 656 | static HKEY |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 657 | winreg_OpenKeyEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, |
| 658 | int reserved, REGSAM access); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 659 | |
| 660 | static PyObject * |
| 661 | winreg_OpenKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) |
| 662 | { |
| 663 | PyObject *return_value = NULL; |
| 664 | static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; |
| 665 | HKEY key; |
| 666 | Py_UNICODE *sub_key; |
| 667 | int reserved = 0; |
| 668 | REGSAM access = KEY_READ; |
| 669 | HKEY _return_value; |
| 670 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 671 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKeyEx", _keywords, |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 672 | clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) |
| 673 | goto exit; |
| 674 | _return_value = winreg_OpenKeyEx_impl(module, key, sub_key, reserved, access); |
| 675 | if (_return_value == NULL) |
| 676 | goto exit; |
| 677 | return_value = PyHKEY_FromHKEY(_return_value); |
| 678 | |
| 679 | exit: |
| 680 | return return_value; |
| 681 | } |
| 682 | |
| 683 | PyDoc_STRVAR(winreg_QueryInfoKey__doc__, |
| 684 | "QueryInfoKey($module, key, /)\n" |
| 685 | "--\n" |
| 686 | "\n" |
| 687 | "Returns information about a key.\n" |
| 688 | "\n" |
| 689 | " key\n" |
| 690 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 691 | "\n" |
| 692 | "The result is a tuple of 3 items:\n" |
| 693 | "An integer that identifies the number of sub keys this key has.\n" |
| 694 | "An integer that identifies the number of values this key has.\n" |
| 695 | "An integer that identifies when the key was last modified (if available)\n" |
| 696 | "as 100\'s of nanoseconds since Jan 1, 1600."); |
| 697 | |
| 698 | #define WINREG_QUERYINFOKEY_METHODDEF \ |
| 699 | {"QueryInfoKey", (PyCFunction)winreg_QueryInfoKey, METH_O, winreg_QueryInfoKey__doc__}, |
| 700 | |
| 701 | static PyObject * |
| 702 | winreg_QueryInfoKey_impl(PyModuleDef *module, HKEY key); |
| 703 | |
| 704 | static PyObject * |
| 705 | winreg_QueryInfoKey(PyModuleDef *module, PyObject *arg) |
| 706 | { |
| 707 | PyObject *return_value = NULL; |
| 708 | HKEY key; |
| 709 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 710 | if (!PyArg_Parse(arg, "O&:QueryInfoKey", clinic_HKEY_converter, &key)) |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 711 | goto exit; |
| 712 | return_value = winreg_QueryInfoKey_impl(module, key); |
| 713 | |
| 714 | exit: |
| 715 | return return_value; |
| 716 | } |
| 717 | |
| 718 | PyDoc_STRVAR(winreg_QueryValue__doc__, |
| 719 | "QueryValue($module, key, sub_key, /)\n" |
| 720 | "--\n" |
| 721 | "\n" |
| 722 | "Retrieves the unnamed value for a key.\n" |
| 723 | "\n" |
| 724 | " key\n" |
| 725 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 726 | " sub_key\n" |
| 727 | " A string that holds the name of the subkey with which the value\n" |
| 728 | " is associated. If this parameter is None or empty, the function\n" |
| 729 | " retrieves the value set by the SetValue() method for the key\n" |
| 730 | " identified by key.\n" |
| 731 | "\n" |
| 732 | "Values in the registry have name, type, and data components. This method\n" |
| 733 | "retrieves the data for a key\'s first value that has a NULL name.\n" |
| 734 | "But since the underlying API call doesn\'t return the type, you\'ll\n" |
| 735 | "probably be happier using QueryValueEx; this function is just here for\n" |
| 736 | "completeness."); |
| 737 | |
| 738 | #define WINREG_QUERYVALUE_METHODDEF \ |
| 739 | {"QueryValue", (PyCFunction)winreg_QueryValue, METH_VARARGS, winreg_QueryValue__doc__}, |
| 740 | |
| 741 | static PyObject * |
| 742 | winreg_QueryValue_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key); |
| 743 | |
| 744 | static PyObject * |
| 745 | winreg_QueryValue(PyModuleDef *module, PyObject *args) |
| 746 | { |
| 747 | PyObject *return_value = NULL; |
| 748 | HKEY key; |
| 749 | Py_UNICODE *sub_key; |
| 750 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 751 | if (!PyArg_ParseTuple(args, "O&Z:QueryValue", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 752 | clinic_HKEY_converter, &key, &sub_key)) |
| 753 | goto exit; |
| 754 | return_value = winreg_QueryValue_impl(module, key, sub_key); |
| 755 | |
| 756 | exit: |
| 757 | return return_value; |
| 758 | } |
| 759 | |
| 760 | PyDoc_STRVAR(winreg_QueryValueEx__doc__, |
| 761 | "QueryValueEx($module, key, name, /)\n" |
| 762 | "--\n" |
| 763 | "\n" |
| 764 | "Retrieves the type and value of a specified sub-key.\n" |
| 765 | "\n" |
| 766 | " key\n" |
| 767 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 768 | " name\n" |
| 769 | " A string indicating the value to query.\n" |
| 770 | "\n" |
| 771 | "Behaves mostly like QueryValue(), but also returns the type of the\n" |
| 772 | "specified value name associated with the given open registry key.\n" |
| 773 | "\n" |
| 774 | "The return value is a tuple of the value and the type_id."); |
| 775 | |
| 776 | #define WINREG_QUERYVALUEEX_METHODDEF \ |
| 777 | {"QueryValueEx", (PyCFunction)winreg_QueryValueEx, METH_VARARGS, winreg_QueryValueEx__doc__}, |
| 778 | |
| 779 | static PyObject * |
| 780 | winreg_QueryValueEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *name); |
| 781 | |
| 782 | static PyObject * |
| 783 | winreg_QueryValueEx(PyModuleDef *module, PyObject *args) |
| 784 | { |
| 785 | PyObject *return_value = NULL; |
| 786 | HKEY key; |
| 787 | Py_UNICODE *name; |
| 788 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 789 | if (!PyArg_ParseTuple(args, "O&Z:QueryValueEx", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 790 | clinic_HKEY_converter, &key, &name)) |
| 791 | goto exit; |
| 792 | return_value = winreg_QueryValueEx_impl(module, key, name); |
| 793 | |
| 794 | exit: |
| 795 | return return_value; |
| 796 | } |
| 797 | |
| 798 | PyDoc_STRVAR(winreg_SaveKey__doc__, |
| 799 | "SaveKey($module, key, file_name, /)\n" |
| 800 | "--\n" |
| 801 | "\n" |
| 802 | "Saves the specified key, and all its subkeys to the specified file.\n" |
| 803 | "\n" |
| 804 | " key\n" |
| 805 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 806 | " file_name\n" |
| 807 | " The name of the file to save registry data to. This file cannot\n" |
| 808 | " already exist. If this filename includes an extension, it cannot be\n" |
| 809 | " used on file allocation table (FAT) file systems by the LoadKey(),\n" |
| 810 | " ReplaceKey() or RestoreKey() methods.\n" |
| 811 | "\n" |
| 812 | "If key represents a key on a remote computer, the path described by\n" |
| 813 | "file_name is relative to the remote computer.\n" |
| 814 | "\n" |
| 815 | "The caller of this method must possess the SeBackupPrivilege\n" |
| 816 | "security privilege. This function passes NULL for security_attributes\n" |
| 817 | "to the API."); |
| 818 | |
| 819 | #define WINREG_SAVEKEY_METHODDEF \ |
| 820 | {"SaveKey", (PyCFunction)winreg_SaveKey, METH_VARARGS, winreg_SaveKey__doc__}, |
| 821 | |
| 822 | static PyObject * |
| 823 | winreg_SaveKey_impl(PyModuleDef *module, HKEY key, Py_UNICODE *file_name); |
| 824 | |
| 825 | static PyObject * |
| 826 | winreg_SaveKey(PyModuleDef *module, PyObject *args) |
| 827 | { |
| 828 | PyObject *return_value = NULL; |
| 829 | HKEY key; |
| 830 | Py_UNICODE *file_name; |
| 831 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 832 | if (!PyArg_ParseTuple(args, "O&u:SaveKey", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 833 | clinic_HKEY_converter, &key, &file_name)) |
| 834 | goto exit; |
| 835 | return_value = winreg_SaveKey_impl(module, key, file_name); |
| 836 | |
| 837 | exit: |
| 838 | return return_value; |
| 839 | } |
| 840 | |
| 841 | PyDoc_STRVAR(winreg_SetValue__doc__, |
| 842 | "SetValue($module, key, sub_key, type, value, /)\n" |
| 843 | "--\n" |
| 844 | "\n" |
| 845 | "Associates a value with a specified key.\n" |
| 846 | "\n" |
| 847 | " key\n" |
| 848 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 849 | " sub_key\n" |
| 850 | " A string that names the subkey with which the value is associated.\n" |
| 851 | " type\n" |
| 852 | " An integer that specifies the type of the data. Currently this must\n" |
| 853 | " be REG_SZ, meaning only strings are supported.\n" |
| 854 | " value\n" |
| 855 | " A string that specifies the new value.\n" |
| 856 | "\n" |
| 857 | "If the key specified by the sub_key parameter does not exist, the\n" |
| 858 | "SetValue function creates it.\n" |
| 859 | "\n" |
| 860 | "Value lengths are limited by available memory. Long values (more than\n" |
| 861 | "2048 bytes) should be stored as files with the filenames stored in\n" |
| 862 | "the configuration registry to help the registry perform efficiently.\n" |
| 863 | "\n" |
| 864 | "The key identified by the key parameter must have been opened with\n" |
| 865 | "KEY_SET_VALUE access."); |
| 866 | |
| 867 | #define WINREG_SETVALUE_METHODDEF \ |
| 868 | {"SetValue", (PyCFunction)winreg_SetValue, METH_VARARGS, winreg_SetValue__doc__}, |
| 869 | |
| 870 | static PyObject * |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 871 | winreg_SetValue_impl(PyModuleDef *module, HKEY key, Py_UNICODE *sub_key, |
| 872 | DWORD type, Py_UNICODE *value, |
| 873 | Py_ssize_clean_t value_length); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 874 | |
| 875 | static PyObject * |
| 876 | winreg_SetValue(PyModuleDef *module, PyObject *args) |
| 877 | { |
| 878 | PyObject *return_value = NULL; |
| 879 | HKEY key; |
| 880 | Py_UNICODE *sub_key; |
| 881 | DWORD type; |
| 882 | Py_UNICODE *value; |
| 883 | Py_ssize_clean_t value_length; |
| 884 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 885 | if (!PyArg_ParseTuple(args, "O&Zku#:SetValue", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 886 | clinic_HKEY_converter, &key, &sub_key, &type, &value, &value_length)) |
| 887 | goto exit; |
| 888 | return_value = winreg_SetValue_impl(module, key, sub_key, type, value, value_length); |
| 889 | |
| 890 | exit: |
| 891 | return return_value; |
| 892 | } |
| 893 | |
| 894 | PyDoc_STRVAR(winreg_SetValueEx__doc__, |
| 895 | "SetValueEx($module, key, value_name, reserved, type, value, /)\n" |
| 896 | "--\n" |
| 897 | "\n" |
| 898 | "Stores data in the value field of an open registry key.\n" |
| 899 | "\n" |
| 900 | " key\n" |
| 901 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 902 | " value_name\n" |
| 903 | " A string containing the name of the value to set, or None.\n" |
| 904 | " reserved\n" |
| 905 | " Can be anything - zero is always passed to the API.\n" |
| 906 | " type\n" |
| 907 | " An integer that specifies the type of the data, one of:\n" |
| 908 | " REG_BINARY -- Binary data in any form.\n" |
| 909 | " REG_DWORD -- A 32-bit number.\n" |
| 910 | " REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format.\n" |
| 911 | " REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.\n" |
| 912 | " REG_EXPAND_SZ -- A null-terminated string that contains unexpanded\n" |
| 913 | " references to environment variables (for example,\n" |
| 914 | " %PATH%).\n" |
| 915 | " REG_LINK -- A Unicode symbolic link.\n" |
Serhiy Storchaka | 6a7b3a7 | 2016-04-17 08:32:47 +0300 | [diff] [blame^] | 916 | " REG_MULTI_SZ -- A sequence of null-terminated strings, terminated\n" |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 917 | " by two null characters. Note that Python handles\n" |
| 918 | " this termination automatically.\n" |
| 919 | " REG_NONE -- No defined value type.\n" |
| 920 | " REG_RESOURCE_LIST -- A device-driver resource list.\n" |
| 921 | " REG_SZ -- A null-terminated string.\n" |
| 922 | " value\n" |
| 923 | " A string that specifies the new value.\n" |
| 924 | "\n" |
| 925 | "This method can also set additional value and type information for the\n" |
| 926 | "specified key. The key identified by the key parameter must have been\n" |
| 927 | "opened with KEY_SET_VALUE access.\n" |
| 928 | "\n" |
| 929 | "To open the key, use the CreateKeyEx() or OpenKeyEx() methods.\n" |
| 930 | "\n" |
| 931 | "Value lengths are limited by available memory. Long values (more than\n" |
| 932 | "2048 bytes) should be stored as files with the filenames stored in\n" |
| 933 | "the configuration registry to help the registry perform efficiently."); |
| 934 | |
| 935 | #define WINREG_SETVALUEEX_METHODDEF \ |
| 936 | {"SetValueEx", (PyCFunction)winreg_SetValueEx, METH_VARARGS, winreg_SetValueEx__doc__}, |
| 937 | |
| 938 | static PyObject * |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 939 | winreg_SetValueEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *value_name, |
| 940 | PyObject *reserved, DWORD type, PyObject *value); |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 941 | |
| 942 | static PyObject * |
| 943 | winreg_SetValueEx(PyModuleDef *module, PyObject *args) |
| 944 | { |
| 945 | PyObject *return_value = NULL; |
| 946 | HKEY key; |
| 947 | Py_UNICODE *value_name; |
| 948 | PyObject *reserved; |
| 949 | DWORD type; |
| 950 | PyObject *value; |
| 951 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 952 | if (!PyArg_ParseTuple(args, "O&ZOkO:SetValueEx", |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 953 | clinic_HKEY_converter, &key, &value_name, &reserved, &type, &value)) |
| 954 | goto exit; |
| 955 | return_value = winreg_SetValueEx_impl(module, key, value_name, reserved, type, value); |
| 956 | |
| 957 | exit: |
| 958 | return return_value; |
| 959 | } |
| 960 | |
| 961 | PyDoc_STRVAR(winreg_DisableReflectionKey__doc__, |
| 962 | "DisableReflectionKey($module, key, /)\n" |
| 963 | "--\n" |
| 964 | "\n" |
| 965 | "Disables registry reflection for 32bit processes running on a 64bit OS.\n" |
| 966 | "\n" |
| 967 | " key\n" |
| 968 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 969 | "\n" |
| 970 | "Will generally raise NotImplemented if executed on a 32bit OS.\n" |
| 971 | "\n" |
| 972 | "If the key is not on the reflection list, the function succeeds but has\n" |
| 973 | "no effect. Disabling reflection for a key does not affect reflection\n" |
| 974 | "of any subkeys."); |
| 975 | |
| 976 | #define WINREG_DISABLEREFLECTIONKEY_METHODDEF \ |
| 977 | {"DisableReflectionKey", (PyCFunction)winreg_DisableReflectionKey, METH_O, winreg_DisableReflectionKey__doc__}, |
| 978 | |
| 979 | static PyObject * |
| 980 | winreg_DisableReflectionKey_impl(PyModuleDef *module, HKEY key); |
| 981 | |
| 982 | static PyObject * |
| 983 | winreg_DisableReflectionKey(PyModuleDef *module, PyObject *arg) |
| 984 | { |
| 985 | PyObject *return_value = NULL; |
| 986 | HKEY key; |
| 987 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 988 | if (!PyArg_Parse(arg, "O&:DisableReflectionKey", clinic_HKEY_converter, &key)) |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 989 | goto exit; |
| 990 | return_value = winreg_DisableReflectionKey_impl(module, key); |
| 991 | |
| 992 | exit: |
| 993 | return return_value; |
| 994 | } |
| 995 | |
| 996 | PyDoc_STRVAR(winreg_EnableReflectionKey__doc__, |
| 997 | "EnableReflectionKey($module, key, /)\n" |
| 998 | "--\n" |
| 999 | "\n" |
| 1000 | "Restores registry reflection for the specified disabled key.\n" |
| 1001 | "\n" |
| 1002 | " key\n" |
| 1003 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 1004 | "\n" |
| 1005 | "Will generally raise NotImplemented if executed on a 32bit OS.\n" |
| 1006 | "Restoring reflection for a key does not affect reflection of any\n" |
| 1007 | "subkeys."); |
| 1008 | |
| 1009 | #define WINREG_ENABLEREFLECTIONKEY_METHODDEF \ |
| 1010 | {"EnableReflectionKey", (PyCFunction)winreg_EnableReflectionKey, METH_O, winreg_EnableReflectionKey__doc__}, |
| 1011 | |
| 1012 | static PyObject * |
| 1013 | winreg_EnableReflectionKey_impl(PyModuleDef *module, HKEY key); |
| 1014 | |
| 1015 | static PyObject * |
| 1016 | winreg_EnableReflectionKey(PyModuleDef *module, PyObject *arg) |
| 1017 | { |
| 1018 | PyObject *return_value = NULL; |
| 1019 | HKEY key; |
| 1020 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 1021 | if (!PyArg_Parse(arg, "O&:EnableReflectionKey", clinic_HKEY_converter, &key)) |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 1022 | goto exit; |
| 1023 | return_value = winreg_EnableReflectionKey_impl(module, key); |
| 1024 | |
| 1025 | exit: |
| 1026 | return return_value; |
| 1027 | } |
| 1028 | |
| 1029 | PyDoc_STRVAR(winreg_QueryReflectionKey__doc__, |
| 1030 | "QueryReflectionKey($module, key, /)\n" |
| 1031 | "--\n" |
| 1032 | "\n" |
| 1033 | "Returns the reflection state for the specified key as a bool.\n" |
| 1034 | "\n" |
| 1035 | " key\n" |
| 1036 | " An already open key, or any one of the predefined HKEY_* constants.\n" |
| 1037 | "\n" |
| 1038 | "Will generally raise NotImplemented if executed on a 32bit OS."); |
| 1039 | |
| 1040 | #define WINREG_QUERYREFLECTIONKEY_METHODDEF \ |
| 1041 | {"QueryReflectionKey", (PyCFunction)winreg_QueryReflectionKey, METH_O, winreg_QueryReflectionKey__doc__}, |
| 1042 | |
| 1043 | static PyObject * |
| 1044 | winreg_QueryReflectionKey_impl(PyModuleDef *module, HKEY key); |
| 1045 | |
| 1046 | static PyObject * |
| 1047 | winreg_QueryReflectionKey(PyModuleDef *module, PyObject *arg) |
| 1048 | { |
| 1049 | PyObject *return_value = NULL; |
| 1050 | HKEY key; |
| 1051 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 1052 | if (!PyArg_Parse(arg, "O&:QueryReflectionKey", clinic_HKEY_converter, &key)) |
Zachary Ware | fd2d482 | 2015-05-13 01:21:57 -0500 | [diff] [blame] | 1053 | goto exit; |
| 1054 | return_value = winreg_QueryReflectionKey_impl(module, key); |
| 1055 | |
| 1056 | exit: |
| 1057 | return return_value; |
| 1058 | } |
Serhiy Storchaka | 6a7b3a7 | 2016-04-17 08:32:47 +0300 | [diff] [blame^] | 1059 | /*[clinic end generated code: output=5e346dccc296f9f1 input=a9049054013a1b77]*/ |