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