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