Changeset 391 for python/trunk/Doc/library/_winreg.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/_winreg.rst
r2 r391 8 8 9 9 .. note:: 10 The :mod:`_winreg` module has been renamed to :mod:`winreg` in Python 3. 0.10 The :mod:`_winreg` module has been renamed to :mod:`winreg` in Python 3. 11 11 The :term:`2to3` tool will automatically adapt imports when converting your 12 sources to 3.0.12 sources to Python 3. 13 13 14 14 … … 16 16 17 17 These functions expose the Windows registry API to Python. Instead of using an 18 integer as the registry handle, a handle object is used to ensure that the 19 handles are closed correctly, even if the programmer neglects to explicitly 20 close them. 21 22 This module exposes a very low-level interface to the Windows registry; it is 23 expected that in the future a new ``winreg`` module will be created offering a 24 higher-level interface to the registry API. 18 integer as the registry handle, a :ref:`handle object <handle-object>` is used 19 to ensure that the handles are closed correctly, even if the programmer neglects 20 to explicitly close them. 25 21 26 22 This module offers the following functions: … … 29 25 .. function:: CloseKey(hkey) 30 26 31 Closes a previously opened registry key. The hkeyargument specifies a27 Closes a previously opened registry key. The *hkey* argument specifies a 32 28 previously opened key. 33 29 34 Note that if *hkey* is not closed using this method (or via35 :meth:`handle.Close`), it is closed when the *hkey* object is destroyed by36 Python.30 .. note:: 31 If *hkey* is not closed using this method (or via :meth:`hkey.Close() <PyHKEY.Close>`), 32 it is closed when the *hkey* object is destroyed by Python. 37 33 38 34 39 35 .. function:: ConnectRegistry(computer_name, key) 40 36 41 Establishes a connection to a predefined registry handle on 42 and returns a : dfn:`handle object`43 44 *computer_name* is the name of the remote computer, of the 37 Establishes a connection to a predefined registry handle on another computer, 38 and returns a :ref:`handle object <handle-object>`. 39 40 *computer_name* is the name of the remote computer, of the form 45 41 ``r"\\computername"``. If ``None``, the local computer is used. 46 42 … … 48 44 49 45 The return value is the handle of the opened key. If the function fails, a 50 :exc:`WindowsError` exception is 46 :exc:`WindowsError` exception is raised. 51 47 52 48 53 49 .. function:: CreateKey(key, sub_key) 54 50 55 Creates or opens the specified key, returning a :dfn:`handle object` 56 57 *key* is an already open key, or one of the predefined :const:`HKEY_\*` 58 constants. 59 60 *sub_key* is a string that names the key this method opens or creates. 61 62 If *key* is one of the predefined keys, *sub_key* may be ``None``. In that 63 case, the handle returned is the same key handle passed in to the function. 51 Creates or opens the specified key, returning a 52 :ref:`handle object <handle-object>`. 53 54 *key* is an already open key, or one of the predefined 55 :ref:`HKEY_* constants <hkey-constants>`. 56 57 *sub_key* is a string that names the key this method opens or creates. 58 59 If *key* is one of the predefined keys, *sub_key* may be ``None``. In that 60 case, the handle returned is the same key handle passed in to the function. 64 61 65 62 If the key already exists, this function opens the existing key. 66 63 67 64 The return value is the handle of the opened key. If the function fails, a 68 :exc:`WindowsError` exception is raised. 65 :exc:`WindowsError` exception is raised. 66 67 68 .. function:: CreateKeyEx(key, sub_key[, res[, sam]]) 69 70 Creates or opens the specified key, returning a 71 :ref:`handle object <handle-object>`. 72 73 *key* is an already open key, or one of the predefined 74 :ref:`HKEY_* constants <hkey-constants>`. 75 76 *sub_key* is a string that names the key this method opens or creates. 77 78 *res* is a reserved integer, and must be zero. The default is zero. 79 80 *sam* is an integer that specifies an access mask that describes the desired 81 security access for the key. Default is :const:`KEY_ALL_ACCESS`. See 82 :ref:`Access Rights <access-rights>` for other allowed values. 83 84 85 If *key* is one of the predefined keys, *sub_key* may be ``None``. In that 86 case, the handle returned is the same key handle passed in to the function. 87 88 If the key already exists, this function opens the existing key. 89 90 The return value is the handle of the opened key. If the function fails, a 91 :exc:`WindowsError` exception is raised. 92 93 .. versionadded:: 2.7 69 94 70 95 … … 73 98 Deletes the specified key. 74 99 75 *key* is an already open key, or any one of the predefined :const:`HKEY_\*`76 constants.77 78 *sub_key* is a string that must be a subkey of the key 79 parameter. This value must not be 100 *key* is an already open key, or any one of the predefined 101 :ref:`HKEY_* constants <hkey-constants>`. 102 103 *sub_key* is a string that must be a subkey of the key identified by the *key* 104 parameter. This value must not be ``None``, and the key may not have subkeys. 80 105 81 106 *This method can not delete keys with subkeys.* 82 107 83 108 If the method succeeds, the entire key, including all of its values, is removed. 84 If the method fails, a :exc:`WindowsError` exception is raised. 109 If the method fails, a :exc:`WindowsError` exception is raised. 110 111 112 .. function:: DeleteKeyEx(key, sub_key[, sam[, res]]) 113 114 Deletes the specified key. 115 116 .. note:: 117 The :func:`DeleteKeyEx` function is implemented with the RegDeleteKeyEx 118 Windows API function, which is specific to 64-bit versions of Windows. 119 See the `RegDeleteKeyEx documentation 120 <http://msdn.microsoft.com/en-us/library/ms724847%28VS.85%29.aspx>`__. 121 122 *key* is an already open key, or any one of the predefined 123 :ref:`HKEY_* constants <hkey-constants>`. 124 125 *sub_key* is a string that must be a subkey of the key identified by the 126 *key* parameter. This value must not be ``None``, and the key may not have 127 subkeys. 128 129 *res* is a reserved integer, and must be zero. The default is zero. 130 131 *sam* is an integer that specifies an access mask that describes the desired 132 security access for the key. Default is :const:`KEY_WOW64_64KEY`. See 133 :ref:`Access Rights <access-rights>` for other allowed values. 134 135 136 *This method can not delete keys with subkeys.* 137 138 If the method succeeds, the entire key, including all of its values, is 139 removed. If the method fails, a :exc:`WindowsError` exception is raised. 140 141 On unsupported Windows versions, :exc:`NotImplementedError` is raised. 142 143 .. versionadded:: 2.7 85 144 86 145 … … 89 148 Removes a named value from a registry key. 90 149 91 *key* is an already open key, or one of the predefined :const:`HKEY_\*`92 constants.150 *key* is an already open key, or one of the predefined 151 :ref:`HKEY_* constants <hkey-constants>`. 93 152 94 153 *value* is a string that identifies the value to remove. … … 99 158 Enumerates subkeys of an open registry key, returning a string. 100 159 101 *key* is an already open key, or any one of the predefined :const:`HKEY_\*`102 constants.103 104 *index* is an integer that identifies the index of the key to 105 106 The function retrieves the name of one subkey each time it 107 typically called repeatedly until a :exc:`WindowsError` exceptionis160 *key* is an already open key, or any one of the predefined 161 :ref:`HKEY_* constants <hkey-constants>`. 162 163 *index* is an integer that identifies the index of the key to retrieve. 164 165 The function retrieves the name of one subkey each time it is called. It is 166 typically called repeatedly until a :exc:`WindowsError` exception is 108 167 raised, indicating, no more values are available. 109 168 … … 113 172 Enumerates values of an open registry key, returning a tuple. 114 173 115 *key* is an already open key, or any one of the predefined :const:`HKEY_\*`116 constants.117 118 *index* is an integer that identifies the index of the value 119 120 The function retrieves the name of one subkey each time it is 121 typically called repeatedly, until a 122 raised, indicating 174 *key* is an already open key, or any one of the predefined 175 :ref:`HKEY_* constants <hkey-constants>`. 176 177 *index* is an integer that identifies the index of the value to retrieve. 178 179 The function retrieves the name of one subkey each time it is called. It is 180 typically called repeatedly, until a :exc:`WindowsError` exception is 181 raised, indicating no more values. 123 182 124 183 The result is a tuple of 3 items: … … 134 193 +-------+--------------------------------------------+ 135 194 | ``2`` | An integer that identifies the type of the | 136 | | value data | 195 | | value data (see table in docs for | 196 | | :meth:`SetValueEx`) | 137 197 +-------+--------------------------------------------+ 138 198 … … 140 200 .. function:: ExpandEnvironmentStrings(unicode) 141 201 142 Expands environment strings %NAME% in unicode string like const:`REG_EXPAND_SZ`:: 202 Expands environment variable placeholders ``%NAME%`` in unicode strings like 203 :const:`REG_EXPAND_SZ`:: 143 204 144 205 >>> ExpandEnvironmentStrings(u"%windir%") … … 152 213 Writes all the attributes of a key to the registry. 153 214 154 *key* is an already open key, or one of the predefined :const:`HKEY_\*`155 constants.215 *key* is an already open key, or one of the predefined 216 :ref:`HKEY_* constants <hkey-constants>`. 156 217 157 218 It is not necessary to call :func:`FlushKey` to change a key. Registry changes are 158 flushed to disk by the registry using its lazy 159 also flushed to disk at system 160 :func:`FlushKey` method 219 flushed to disk by the registry using its lazy flusher. Registry changes are 220 also flushed to disk at system shutdown. Unlike :func:`CloseKey`, the 221 :func:`FlushKey` method returns only when all the data has been written to the 161 222 registry. An application should only call :func:`FlushKey` if it requires 162 absolute 223 absolute certainty that registry changes are on disk. 163 224 164 225 .. note:: 165 226 166 If you don't know whether a :func:`FlushKey` call is required, it 227 If you don't know whether a :func:`FlushKey` call is required, it probably 167 228 isn't. 168 229 … … 170 231 .. function:: LoadKey(key, sub_key, file_name) 171 232 172 Creates a subkey under the specified key and stores registration 233 Creates a subkey under the specified key and stores registration information 173 234 from a specified file into that subkey. 174 235 175 *key* is a n already open key, or any of the predefined :const:`HKEY_\*`176 constants.177 178 *sub_key* is a string that identifies the sub _key to load.236 *key* is a handle returned by :func:`ConnectRegistry` or one of the constants 237 :const:`HKEY_USERS` or :const:`HKEY_LOCAL_MACHINE`. 238 239 *sub_key* is a string that identifies the subkey to load. 179 240 180 241 *file_name* is the name of the file to load registry data from. This file must … … 182 243 table (FAT) file system, the filename may not have an extension. 183 244 184 A call to LoadKey() fails if the calling process does not have the 185 :const:`SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different than 186 permissions - see the Win32 documentation for more details. 187 188 If *key* is a handle returned by :func:`ConnectRegistry`, then the path 189 specified in *fileName* is relative to the remote computer. 190 191 The Win32 documentation implies *key* must be in the :const:`HKEY_USER` or 192 :const:`HKEY_LOCAL_MACHINE` tree. This may or may not be true. 193 194 195 .. function:: OpenKey(key, sub_key[, res=0][, sam=KEY_READ]) 196 197 Opens the specified key, returning a :dfn:`handle object` 198 199 *key* is an already open key, or any one of the predefined :const:`HKEY_\*` 200 constants. 245 A call to :func:`LoadKey` fails if the calling process does not have the 246 :const:`SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different 247 from permissions -- see the `RegLoadKey documentation 248 <http://msdn.microsoft.com/en-us/library/ms724889%28v=VS.85%29.aspx>`__ for 249 more details. 250 251 If *key* is a handle returned by :func:`ConnectRegistry`, then the path 252 specified in *file_name* is relative to the remote computer. 253 254 255 .. function:: OpenKey(key, sub_key[, res[, sam]]) 256 257 Opens the specified key, returning a :ref:`handle object <handle-object>`. 258 259 *key* is an already open key, or any one of the predefined 260 :ref:`HKEY_* constants <hkey-constants>`. 201 261 202 262 *sub_key* is a string that identifies the sub_key to open. … … 204 264 *res* is a reserved integer, and must be zero. The default is zero. 205 265 206 *sam* is an integer that specifies an access mask that describes the desired 207 security access for the key. Default is :const:`KEY_READ` 266 *sam* is an integer that specifies an access mask that describes the desired 267 security access for the key. Default is :const:`KEY_READ`. See 268 :ref:`Access Rights <access-rights>` for other allowed values. 208 269 209 270 The result is a new handle to the specified key. … … 214 275 .. function:: OpenKeyEx() 215 276 216 The functionality of :func:`OpenKeyEx` is provided via :func:`OpenKey`, by the217 use of default arguments.277 The functionality of :func:`OpenKeyEx` is provided via :func:`OpenKey`, 278 by the use of default arguments. 218 279 219 280 … … 222 283 Returns information about a key, as a tuple. 223 284 224 *key* is an already open key, or one of the predefined :const:`HKEY_\*`225 constants.285 *key* is an already open key, or one of the predefined 286 :ref:`HKEY_* constants <hkey-constants>`. 226 287 227 288 The result is a tuple of 3 items: … … 244 305 .. function:: QueryValue(key, sub_key) 245 306 246 Retrieves the unnamed value for a key, as a string 247 248 *key* is an already open key, or one of the predefined :const:`HKEY_\*`249 constants.250 251 *sub_key* is a string that holds the name of the subkey with which 252 associated. If this parameter is ``None`` or empty, the 253 value set by the :func:`SetValue` method 307 Retrieves the unnamed value for a key, as a string. 308 309 *key* is an already open key, or one of the predefined 310 :ref:`HKEY_* constants <hkey-constants>`. 311 312 *sub_key* is a string that holds the name of the subkey with which the value is 313 associated. If this parameter is ``None`` or empty, the function retrieves the 314 value set by the :func:`SetValue` method for the key identified by *key*. 254 315 255 316 Values in the registry have name, type, and data components. This method … … 261 322 .. function:: QueryValueEx(key, value_name) 262 323 263 Retrieves the type and data for a specified value name associated with an open264 registry key.265 266 *key* is an already open key, or one of the predefined :const:`HKEY_\*`267 constants.324 Retrieves the type and data for a specified value name associated with 325 an open registry key. 326 327 *key* is an already open key, or one of the predefined 328 :ref:`HKEY_* constants <hkey-constants>`. 268 329 269 330 *value_name* is a string indicating the value to query. … … 277 338 +-------+-----------------------------------------+ 278 339 | ``1`` | An integer giving the registry type for | 279 | | this value. | 340 | | this value (see table in docs for | 341 | | :meth:`SetValueEx`) | 280 342 +-------+-----------------------------------------+ 281 343 … … 285 347 Saves the specified key, and all its subkeys to the specified file. 286 348 287 *key* is an already open key, or one of the predefined :const:`HKEY_\*`288 constants.289 290 *file_name* is the name of the file to save registry data to. This file cannot291 already exist. If this filename includes an extension, it cannot be used on file292 allocation table (FAT) file systems by the :meth:`LoadKey`, :meth:`ReplaceKey`293 or :meth:`RestoreKey` methods.294 295 If *key* represents a key on a remote computer, the path 349 *key* is an already open key, or one of the predefined 350 :ref:`HKEY_* constants <hkey-constants>`. 351 352 *file_name* is the name of the file to save registry data to. This file 353 cannot already exist. If this filename includes an extension, it cannot be 354 used on file allocation table (FAT) file systems by the :meth:`LoadKey` 355 method. 356 357 If *key* represents a key on a remote computer, the path described by 296 358 *file_name* is relative to the remote computer. The caller of this method must 297 possess the :const:`SeBackupPrivilege` security privilege. Note that 298 privileges are different than permissions - see the Win32 documentation for 299 more details. 359 possess the :const:`SeBackupPrivilege` security privilege. Note that 360 privileges are different than permissions -- see the 361 `Conflicts Between User Rights and Permissions documentation 362 <http://msdn.microsoft.com/en-us/library/ms724878%28v=VS.85%29.aspx>`__ 363 for more details. 300 364 301 365 This function passes NULL for *security_attributes* to the API. … … 306 370 Associates a value with a specified key. 307 371 308 *key* is an already open key, or one of the predefined :const:`HKEY_\*`309 constants.310 311 *sub_key* is a string that names the subkey with which the value 372 *key* is an already open key, or one of the predefined 373 :ref:`HKEY_* constants <hkey-constants>`. 374 375 *sub_key* is a string that names the subkey with which the value is associated. 312 376 313 377 *type* is an integer that specifies the type of the data. Currently this must be … … 324 388 registry. This helps the registry perform efficiently. 325 389 326 The key identified by the *key* parameter must have been 390 The key identified by the *key* parameter must have been opened with 327 391 :const:`KEY_SET_VALUE` access. 328 392 … … 332 396 Stores data in the value field of an open registry key. 333 397 334 *key* is an already open key, or one of the predefined :const:`HKEY_\*`335 constants.336 337 *value_name* is a string that names the subkey with which the 398 *key* is an already open key, or one of the predefined 399 :ref:`HKEY_* constants <hkey-constants>`. 400 401 *value_name* is a string that names the subkey with which the value is 338 402 associated. 339 403 340 *type* is an integer that specifies the type of the data. This should be one 341 of the following constants defined in this module: 342 343 +----------------------------------+---------------------------------------------+ 344 | Constant | Meaning | 345 +==================================+=============================================+ 346 | :const:`REG_BINARY` | Binary data in any form. | 347 +----------------------------------+---------------------------------------------+ 348 | :const:`REG_DWORD` | A 32-bit number. | 349 +----------------------------------+---------------------------------------------+ 350 | :const:`REG_DWORD_LITTLE_ENDIAN` | A 32-bit number in little-endian format. | 351 +----------------------------------+---------------------------------------------+ 352 | :const:`REG_DWORD_BIG_ENDIAN` | A 32-bit number in big-endian format. | 353 +----------------------------------+---------------------------------------------+ 354 | :const:`REG_EXPAND_SZ` | Null-terminated string containing | 355 | | references to environment variables | 356 | | (``%PATH%``). | 357 +----------------------------------+---------------------------------------------+ 358 | :const:`REG_LINK` | A Unicode symbolic link. | 359 +----------------------------------+---------------------------------------------+ 360 | :const:`REG_MULTI_SZ` | A sequence of null-terminated strings, | 361 | | terminated by two null characters. (Python | 362 | | handles this termination automatically.) | 363 +----------------------------------+---------------------------------------------+ 364 | :const:`REG_NONE` | No defined value type. | 365 +----------------------------------+---------------------------------------------+ 366 | :const:`REG_RESOURCE_LIST` | A device-driver resource list. | 367 +----------------------------------+---------------------------------------------+ 368 | :const:`REG_SZ` | A null-terminated string. | 369 +----------------------------------+---------------------------------------------+ 370 371 *reserved* can be anything - zero is always passed to the API. 404 *type* is an integer that specifies the type of the data. See 405 :ref:`Value Types <value-types>` for the available types. 406 407 *reserved* can be anything -- zero is always passed to the API. 372 408 373 409 *value* is a string that specifies the new value. … … 377 413 :const:`KEY_SET_VALUE` access. 378 414 379 To open the key, use the :func:`CreateKey` or 415 To open the key, use the :func:`CreateKey` or :func:`OpenKey` methods. 380 416 381 417 Value lengths are limited by available memory. Long values (more than 2048 … … 384 420 385 421 422 .. function:: DisableReflectionKey(key) 423 424 Disables registry reflection for 32-bit processes running on a 64-bit 425 operating system. 426 427 *key* is an already open key, or one of the predefined 428 :ref:`HKEY_* constants <hkey-constants>`. 429 430 Will generally raise :exc:`NotImplemented` if executed on a 32-bit 431 operating system. 432 433 If the key is not on the reflection list, the function succeeds but has no 434 effect. Disabling reflection for a key does not affect reflection of any 435 subkeys. 436 437 438 .. function:: EnableReflectionKey(key) 439 440 Restores registry reflection for the specified disabled key. 441 442 *key* is an already open key, or one of the predefined 443 :ref:`HKEY_* constants <hkey-constants>`. 444 445 Will generally raise :exc:`NotImplemented` if executed on a 32-bit 446 operating system. 447 448 Restoring reflection for a key does not affect reflection of any subkeys. 449 450 451 .. function:: QueryReflectionKey(key) 452 453 Determines the reflection state for the specified key. 454 455 *key* is an already open key, or one of the predefined 456 :ref:`HKEY_* constants <hkey-constants>`. 457 458 Returns ``True`` if reflection is disabled. 459 460 Will generally raise :exc:`NotImplemented` if executed on a 32-bit 461 operating system. 462 463 464 .. _constants: 465 466 Constants 467 ------------------ 468 469 The following constants are defined for use in many :mod:`_winreg` functions. 470 471 .. _hkey-constants: 472 473 HKEY_* Constants 474 ++++++++++++++++ 475 476 .. data:: HKEY_CLASSES_ROOT 477 478 Registry entries subordinate to this key define types (or classes) of 479 documents and the properties associated with those types. Shell and 480 COM applications use the information stored under this key. 481 482 483 .. data:: HKEY_CURRENT_USER 484 485 Registry entries subordinate to this key define the preferences of 486 the current user. These preferences include the settings of 487 environment variables, data about program groups, colors, printers, 488 network connections, and application preferences. 489 490 .. data:: HKEY_LOCAL_MACHINE 491 492 Registry entries subordinate to this key define the physical state 493 of the computer, including data about the bus type, system memory, 494 and installed hardware and software. 495 496 .. data:: HKEY_USERS 497 498 Registry entries subordinate to this key define the default user 499 configuration for new users on the local computer and the user 500 configuration for the current user. 501 502 .. data:: HKEY_PERFORMANCE_DATA 503 504 Registry entries subordinate to this key allow you to access 505 performance data. The data is not actually stored in the registry; 506 the registry functions cause the system to collect the data from 507 its source. 508 509 510 .. data:: HKEY_CURRENT_CONFIG 511 512 Contains information about the current hardware profile of the 513 local computer system. 514 515 .. data:: HKEY_DYN_DATA 516 517 This key is not used in versions of Windows after 98. 518 519 520 .. _access-rights: 521 522 Access Rights 523 +++++++++++++ 524 525 For more information, see `Registry Key Security and Access 526 <http://msdn.microsoft.com/en-us/library/ms724878%28v=VS.85%29.aspx>`__. 527 528 .. data:: KEY_ALL_ACCESS 529 530 Combines the STANDARD_RIGHTS_REQUIRED, :const:`KEY_QUERY_VALUE`, 531 :const:`KEY_SET_VALUE`, :const:`KEY_CREATE_SUB_KEY`, 532 :const:`KEY_ENUMERATE_SUB_KEYS`, :const:`KEY_NOTIFY`, 533 and :const:`KEY_CREATE_LINK` access rights. 534 535 .. data:: KEY_WRITE 536 537 Combines the STANDARD_RIGHTS_WRITE, :const:`KEY_SET_VALUE`, and 538 :const:`KEY_CREATE_SUB_KEY` access rights. 539 540 .. data:: KEY_READ 541 542 Combines the STANDARD_RIGHTS_READ, :const:`KEY_QUERY_VALUE`, 543 :const:`KEY_ENUMERATE_SUB_KEYS`, and :const:`KEY_NOTIFY` values. 544 545 .. data:: KEY_EXECUTE 546 547 Equivalent to :const:`KEY_READ`. 548 549 .. data:: KEY_QUERY_VALUE 550 551 Required to query the values of a registry key. 552 553 .. data:: KEY_SET_VALUE 554 555 Required to create, delete, or set a registry value. 556 557 .. data:: KEY_CREATE_SUB_KEY 558 559 Required to create a subkey of a registry key. 560 561 .. data:: KEY_ENUMERATE_SUB_KEYS 562 563 Required to enumerate the subkeys of a registry key. 564 565 .. data:: KEY_NOTIFY 566 567 Required to request change notifications for a registry key or for 568 subkeys of a registry key. 569 570 .. data:: KEY_CREATE_LINK 571 572 Reserved for system use. 573 574 575 .. _64-bit-access-rights: 576 577 64-bit Specific 578 *************** 579 580 For more information, see `Accesing an Alternate Registry View 581 <http://msdn.microsoft.com/en-us/library/aa384129(v=VS.85).aspx>`__. 582 583 .. data:: KEY_WOW64_64KEY 584 585 Indicates that an application on 64-bit Windows should operate on 586 the 64-bit registry view. 587 588 .. data:: KEY_WOW64_32KEY 589 590 Indicates that an application on 64-bit Windows should operate on 591 the 32-bit registry view. 592 593 594 .. _value-types: 595 596 Value Types 597 +++++++++++ 598 599 For more information, see `Registry Value Types 600 <http://msdn.microsoft.com/en-us/library/ms724884%28v=VS.85%29.aspx>`__. 601 602 .. data:: REG_BINARY 603 604 Binary data in any form. 605 606 .. data:: REG_DWORD 607 608 32-bit number. 609 610 .. data:: REG_DWORD_LITTLE_ENDIAN 611 612 A 32-bit number in little-endian format. 613 614 .. data:: REG_DWORD_BIG_ENDIAN 615 616 A 32-bit number in big-endian format. 617 618 .. data:: REG_EXPAND_SZ 619 620 Null-terminated string containing references to environment 621 variables (``%PATH%``). 622 623 .. data:: REG_LINK 624 625 A Unicode symbolic link. 626 627 .. data:: REG_MULTI_SZ 628 629 A sequence of null-terminated strings, terminated by two null characters. 630 (Python handles this termination automatically.) 631 632 .. data:: REG_NONE 633 634 No defined value type. 635 636 .. data:: REG_RESOURCE_LIST 637 638 A device-driver resource list. 639 640 .. data:: REG_FULL_RESOURCE_DESCRIPTOR 641 642 A hardware setting. 643 644 .. data:: REG_RESOURCE_REQUIREMENTS_LIST 645 646 A hardware resource list. 647 648 .. data:: REG_SZ 649 650 A null-terminated string. 651 652 386 653 .. _handle-object: 387 654 … … 391 658 This object wraps a Windows HKEY object, automatically closing it when the 392 659 object is destroyed. To guarantee cleanup, you can call either the 393 :meth:` Close` method on the object, or the:func:`CloseKey` function.660 :meth:`~PyHKEY.Close` method on the object, or the :func:`CloseKey` function. 394 661 395 662 All registry functions in this module return one of these objects. 396 663 397 All registry functions in this module which accept a handle object 398 an integer, however, use of the handle object is 399 400 Handle objects provide semantics for :meth:`__nonzero__` - thus::664 All registry functions in this module which accept a handle object also accept 665 an integer, however, use of the handle object is encouraged. 666 667 Handle objects provide semantics for :meth:`__nonzero__` -- thus:: 401 668 402 669 if handle: … … 411 678 Handle objects can be converted to an integer (e.g., using the built-in 412 679 :func:`int` function), in which case the underlying Windows handle value is 413 returned. You can also use the :meth:`Detach` method to return the integer414 handle, and also disconnect the Windows handle from the handle object.680 returned. You can also use the :meth:`~PyHKEY.Detach` method to return the 681 integer handle, and also disconnect the Windows handle from the handle object. 415 682 416 683 … … 431 698 432 699 After calling this function, the handle is effectively invalidated, but the 433 handle is not closed. You would call this function when 434 underlying Win32 handle to exist beyond the lifetime 700 handle is not closed. You would call this function when you need the 701 underlying Win32 handle to exist beyond the lifetime of the handle object. 435 702 436 703 .. method:: PyHKEY.__enter__() 437 704 PyHKEY.__exit__(\*exc_info) 438 705 439 The HKEY object implements :meth:`__enter__` and :meth:`__exit__` and thus 440 supports the context protocol for the :keyword:`with` statement:: 706 The HKEY object implements :meth:`~object.__enter__` and 707 :meth:`~object.__exit__` and thus supports the context protocol for the 708 :keyword:`with` statement:: 441 709 442 710 with OpenKey(HKEY_LOCAL_MACHINE, "foo") as key: 443 # ... work with key ...711 ... # work with key 444 712 445 713 will automatically close *key* when control leaves the :keyword:`with` block.
Note:
See TracChangeset
for help on using the changeset viewer.