Mercurial > cpython-lru_cache-weakref
annotate PC/_winreg.c @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | af9b6c43804e |
| children | 9145f58f7499 |
| rev | line source |
|---|---|
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /* |
|
13131
05cc45d57a7f
Update the module name to _winreg, pending checkin of Paul Prescod's
Fred Drake <fdrake@acm.org>
parents:
12901
diff
changeset
|
2 _winreg.c |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 Windows Registry access module for Python. |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 * Simple registry access written by Mark Hammond in win32api |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 module circa 1995. |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 * Bill Tutt expanded the support significantly not long after. |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 * Numerous other people have submitted patches since then. |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 * Ripped from win32api module 03-Feb-2000 by Mark Hammond, and |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 basic Unicode support added. |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 #include "Python.h" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 #include "structmember.h" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 #include "malloc.h" /* for alloca */ |
|
41884
389077a54fce
Include <windows.h> after python.h, so that WINNT is properly set before windows.h is included. Fixes warnings in PC builds.
Kristján Valur Jónsson <kristjan@ccpgames.com>
parents:
41525
diff
changeset
|
18 #include "windows.h" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 static PyObject *PyHKEY_FromHKEY(HKEY h); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 static BOOL PyHKEY_Close(PyObject *obHandle); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 static char errNotAHandle[] = "Object is not a handle"; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 /* The win32api module reports the function name that failed, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 but this concept is not in the Python core. |
|
51775
af9b6c43804e
Issue #5341: Fix a variety of spelling errors.
Mark Dickinson <dickinsm@gmail.com>
parents:
50781
diff
changeset
|
28 Hopefully it will one day, and in the meantime I don't |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 want to lose this info... |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 #define PyErr_SetFromWindowsErrWithFunction(rc, fnname) \ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 PyErr_SetFromWindowsErr(rc) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 /* Forward declares */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 /* Doc strings */ |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
37 PyDoc_STRVAR(module_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 "This module provides access to the Windows registry API.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 "Functions:\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 "CloseKey() - Closes a registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 "ConnectRegistry() - Establishes a connection to a predefined registry handle\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 " on another computer.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 "CreateKey() - Creates the specified key, or opens it if it already exists.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 "DeleteKey() - Deletes the specified key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 "DeleteValue() - Removes a named value from the specified registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 "EnumKey() - Enumerates subkeys of the specified open registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 "EnumValue() - Enumerates values of the specified open registry key.\n" |
|
44598
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
50 "ExpandEnvironmentStrings() - Expand the env strings in a REG_EXPAND_SZ string.\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 "FlushKey() - Writes all the attributes of the specified key to the registry.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 "LoadKey() - Creates a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and stores\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 " registration information from a specified file into that subkey.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 "OpenKey() - Alias for <om win32api.RegOpenKeyEx>\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 "OpenKeyEx() - Opens the specified key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 "QueryValue() - Retrieves the value associated with the unnamed value for a\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 " specified key in the registry.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 "QueryValueEx() - Retrieves the type and data for a specified value name\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 " associated with an open registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 "QueryInfoKey() - Returns information about the specified key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 "SaveKey() - Saves the specified key, and all its subkeys a file.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 "SetValue() - Associates a value with a specified key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 "SetValueEx() - Stores data in the value field of an open registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 "Special objects:\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 "HKEYType -- type object for HKEY objects\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 "error -- exception raised for Win32 errors\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 "Integer constants:\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 "Many constants are defined - see the documentation for each function\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
72 "to see what constants are used, and where."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
75 PyDoc_STRVAR(CloseKey_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 "CloseKey(hkey) - Closes a previously opened registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 "The hkey argument specifies a previously opened key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 "Note that if the key is not closed using this method, it will be\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
81 "closed when the hkey object is destroyed by Python."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
83 PyDoc_STRVAR(ConnectRegistry_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 "key = ConnectRegistry(computer_name, key) - " |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 "Establishes a connection to a predefined registry handle on another computer.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 "computer_name is the name of the remote computer, of the form \\\\computername.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 " If None, the local computer is used.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 "key is the predefined handle to connect to.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 "The return value is the handle of the opened key.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
92 "If the function fails, an EnvironmentError exception is raised."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
94 PyDoc_STRVAR(CreateKey_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 "key = CreateKey(key, sub_key) - Creates or opens the specified key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 "key is an already open key, or one of the predefined HKEY_* constants\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 "sub_key is a string that names the key this method opens or creates.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 " If key is one of the predefined keys, sub_key may be None. In that case,\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 " the handle returned is the same key handle passed in to the function.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 "If the key already exists, this function opens the existing key\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 "The return value is the handle of the opened key.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
105 "If the function fails, an exception is raised."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
107 PyDoc_STRVAR(DeleteKey_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 "DeleteKey(key, sub_key) - Deletes the specified key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 "sub_key is a string that must be a subkey of the key identified by the key parameter.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 " This value must not be None, and the key may not have subkeys.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 "This method can not delete keys with subkeys.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 "If the method succeeds, the entire key, including all of its values,\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
117 "is removed. If the method fails, an EnvironmentError exception is raised."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
119 PyDoc_STRVAR(DeleteValue_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 "DeleteValue(key, value) - Removes a named value from a registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
123 "value is a string that identifies the value to remove."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
125 PyDoc_STRVAR(EnumKey_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 "string = EnumKey(key, index) - Enumerates subkeys of an open registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 "index is an integer that identifies the index of the key to retrieve.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 "The function retrieves the name of one subkey each time it is called.\n" |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
132 "It is typically called repeatedly until an EnvironmentError exception is\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
133 "raised, indicating no more values are available."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
135 PyDoc_STRVAR(EnumValue_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 "tuple = EnumValue(key, index) - Enumerates values of an open registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 "index is an integer that identifies the index of the value to retrieve.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 "The function retrieves the name of one subkey each time it is called.\n" |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
141 "It is typically called repeatedly, until an EnvironmentError exception\n" |
|
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
142 "is raised, indicating no more values.\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 "The result is a tuple of 3 items:\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 "value_name is a string that identifies the value.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 "value_data is an object that holds the value data, and whose type depends\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 " on the underlying registry type.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
148 "data_type is an integer that identifies the type of the value data."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 |
|
44598
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
150 PyDoc_STRVAR(ExpandEnvironmentStrings_doc, |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
151 "string = ExpandEnvironmentStrings(string) - Expand environment vars.\n"); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
152 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
153 PyDoc_STRVAR(FlushKey_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
154 "FlushKey(key) - Writes all the attributes of a key to the registry.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 "It is not necessary to call RegFlushKey to change a key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
159 "Registry changes are flushed to disk by the registry using its lazy flusher.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 "Registry changes are also flushed to disk at system shutdown.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 "Unlike CloseKey(), the FlushKey() method returns only when all the data has\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 "been written to the registry.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 "An application should only call FlushKey() if it requires absolute certainty that registry changes are on disk.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
164 "If you don't know whether a FlushKey() call is required, it probably isn't."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
166 PyDoc_STRVAR(LoadKey_doc, |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
167 "LoadKey(key, sub_key, file_name) - Creates a subkey under the specified key\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 "and stores registration information from a specified file into that subkey.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 "sub_key is a string that identifies the sub_key to load\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 "file_name is the name of the file to load registry data from.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 " This file must have been created with the SaveKey() function.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 " Under the file allocation table (FAT) file system, the filename may not\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 "have an extension.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 "A call to LoadKey() fails if the calling process does not have the\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 "SE_RESTORE_PRIVILEGE privilege.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 "If key is a handle returned by ConnectRegistry(), then the path specified\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 "in fileName is relative to the remote computer.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 "\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
183 "The docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE tree"); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
185 PyDoc_STRVAR(OpenKey_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
186 "key = OpenKey(key, sub_key, res = 0, sam = KEY_READ) - Opens the specified key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 "sub_key is a string that identifies the sub_key to open\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
190 "res is a reserved integer, and must be zero. Default is zero.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 "sam is an integer that specifies an access mask that describes the desired\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 " security access for the key. Default is KEY_READ\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 "The result is a new handle to the specified key\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
195 "If the function fails, an EnvironmentError exception is raised."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
197 PyDoc_STRVAR(OpenKeyEx_doc, "See OpenKey()"); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
199 PyDoc_STRVAR(QueryInfoKey_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 "tuple = QueryInfoKey(key) - Returns information about a key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
203 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 "The result is a tuple of 3 items:" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 "An integer that identifies the number of sub keys this key has.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 "An integer that identifies the number of values this key has.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 "A long integer that identifies when the key was last modified (if available)\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
208 " as 100's of nanoseconds since Jan 1, 1600."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
210 PyDoc_STRVAR(QueryValue_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 "string = QueryValue(key, sub_key) - retrieves the unnamed value for a key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
214 "sub_key is a string that holds the name of the subkey with which the value\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 " is associated. If this parameter is None or empty, the function retrieves\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 " the value set by the SetValue() method for the key identified by key." |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 "Values in the registry have name, type, and data components. This method\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 "retrieves the data for a key's first value that has a NULL name.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
220 "But the underlying API call doesn't return the type, Lame Lame Lame, DONT USE THIS!!!"); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
222 PyDoc_STRVAR(QueryValueEx_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
223 "value,type_id = QueryValueEx(key, value_name) - Retrieves the type and data for a specified value name associated with an open registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
226 "value_name is a string indicating the value to query"); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
228 PyDoc_STRVAR(SaveKey_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 "SaveKey(key, file_name) - Saves the specified key, and all its subkeys to the specified file.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 "file_name is the name of the file to save registry data to.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
233 " This file cannot already exist. If this filename includes an extension,\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 " it cannot be used on file allocation table (FAT) file systems by the\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 " LoadKey(), ReplaceKey() or RestoreKey() methods.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 "If key represents a key on a remote computer, the path described by\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 "file_name is relative to the remote computer.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 "The caller of this method must possess the SeBackupPrivilege security privilege.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
240 "This function passes NULL for security_attributes to the API."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
242 PyDoc_STRVAR(SetValue_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
243 "SetValue(key, sub_key, type, value) - Associates a value with a specified key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
244 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
245 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 "sub_key is a string that names the subkey with which the value is associated.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 "type is an integer that specifies the type of the data. Currently this\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 " must be REG_SZ, meaning only strings are supported.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 "value is a string that specifies the new value.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
251 "If the key specified by the sub_key parameter does not exist, the SetValue\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
252 "function creates it.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
253 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
254 "Value lengths are limited by available memory. Long values (more than\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
255 "2048 bytes) should be stored as files with the filenames stored in \n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
256 "the configuration registry. This helps the registry perform efficiently.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
257 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
258 "The key identified by the key parameter must have been opened with\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
259 "KEY_SET_VALUE access."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
261 PyDoc_STRVAR(SetValueEx_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 "SetValueEx(key, value_name, reserved, type, value) - Stores data in the value field of an open registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
263 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 "key is an already open key, or any one of the predefined HKEY_* constants.\n" |
|
27259
faf256a59ece
Correct docstring for SetValueEx()
Mark Hammond <mhammond@skippinet.com.au>
parents:
26735
diff
changeset
|
265 "value_name is a string containing the name of the value to set, or None\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 "type is an integer that specifies the type of the data. This should be one of:\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
267 " REG_BINARY -- Binary data in any form.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
268 " REG_DWORD -- A 32-bit number.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
269 " REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
270 " REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
271 " REG_EXPAND_SZ -- A null-terminated string that contains unexpanded references\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
272 " to environment variables (for example, %PATH%).\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
273 " REG_LINK -- A Unicode symbolic link.\n" |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
274 " REG_MULTI_SZ -- An sequence of null-terminated strings, terminated by\n" |
|
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
275 " two null characters. Note that Python handles this\n" |
|
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
276 " termination automatically.\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
277 " REG_NONE -- No defined value type.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
278 " REG_RESOURCE_LIST -- A device-driver resource list.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 " REG_SZ -- A null-terminated string.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
280 "reserved can be anything - zero is always passed to the API.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
281 "value is a string that specifies the new value.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
282 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
283 "This method can also set additional value and type information for the\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
284 "specified key. The key identified by the key parameter must have been\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 "opened with KEY_SET_VALUE access.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
286 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
287 "To open the key, use the CreateKeyEx() or OpenKeyEx() methods.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
288 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
289 "Value lengths are limited by available memory. Long values (more than\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
290 "2048 bytes) should be stored as files with the filenames stored in \n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
291 "the configuration registry. This helps the registry perform efficiently."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
292 |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
293 PyDoc_STRVAR(DisableReflectionKey_doc, |
|
46352
63a0d33c4cd3
Typographical fix: 32bit -> 32-bit, 64bit -> 64-bit
Andrew M. Kuchling <amk@amk.ca>
parents:
46320
diff
changeset
|
294 "Disables registry reflection for 32-bit processes running on a 64-bit\n" |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
295 "Operating System. Will generally raise NotImplemented if executed on\n" |
|
46352
63a0d33c4cd3
Typographical fix: 32bit -> 32-bit, 64bit -> 64-bit
Andrew M. Kuchling <amk@amk.ca>
parents:
46320
diff
changeset
|
296 "a 32-bit Operating System.\n" |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
297 "If the key is not on the reflection list, the function succeeds but has no effect.\n" |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
298 "Disabling reflection for a key does not affect reflection of any subkeys."); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
299 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
300 PyDoc_STRVAR(EnableReflectionKey_doc, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
301 "Restores registry reflection for the specified disabled key.\n" |
|
46352
63a0d33c4cd3
Typographical fix: 32bit -> 32-bit, 64bit -> 64-bit
Andrew M. Kuchling <amk@amk.ca>
parents:
46320
diff
changeset
|
302 "Will generally raise NotImplemented if executed on a 32-bit Operating System.\n" |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
303 "Restoring reflection for a key does not affect reflection of any subkeys."); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
304 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
305 PyDoc_STRVAR(QueryReflectionKey_doc, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
306 "bool = QueryReflectionKey(hkey) - Determines the reflection state for the specified key.\n" |
|
46352
63a0d33c4cd3
Typographical fix: 32bit -> 32-bit, 64bit -> 64-bit
Andrew M. Kuchling <amk@amk.ca>
parents:
46320
diff
changeset
|
307 "Will generally raise NotImplemented if executed on a 32-bit Operating System.\n"); |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
308 |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 /* PyHKEY docstrings */ |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
310 PyDoc_STRVAR(PyHKEY_doc, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 "PyHKEY Object - A Python object, representing a win32 registry key.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 "\n" |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
313 "This object wraps a Windows HKEY object, automatically closing it when\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 "the object is destroyed. To guarantee cleanup, you can call either\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 "the Close() method on the PyHKEY, or the CloseKey() method.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 "All functions which accept a handle object also accept an integer - \n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 "however, use of the handle object is encouraged.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 "Functions:\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 "Close() - Closes the underlying handle.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
322 "Detach() - Returns the integer Win32 handle, detaching it from the object\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
323 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 "Properties:\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 "handle - The integer Win32 handle.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
326 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 "Operations:\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 "__nonzero__ - Handles with an open object return true, otherwise false.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 "__int__ - Converting a handle to an integer returns the Win32 handle.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
330 "__cmp__ - Handle objects are compared using the handle value."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
333 PyDoc_STRVAR(PyHKEY_Close_doc, |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
334 "key.Close() - Closes the underlying Windows handle.\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 "\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
336 "If the handle is already closed, no error is raised."); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
337 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
338 PyDoc_STRVAR(PyHKEY_Detach_doc, |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
339 "int = key.Detach() - Detaches the Windows handle from the handle object.\n" |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
340 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
341 "The result is the value of the handle before it is detached. If the\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
342 "handle is already detached, this will return zero.\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
343 "\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
344 "After calling this function, the handle is effectively invalidated,\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
345 "but the handle is not closed. You would call this function when you\n" |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 "need the underlying win32 handle to exist beyond the lifetime of the\n" |
|
12901
eff2410685cc
Cleanup a few docstrings.
Mark Hammond <mhammond@skippinet.com.au>
parents:
12576
diff
changeset
|
347 "handle object.\n" |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
22705
diff
changeset
|
348 "On 64 bit windows, the result of this function is a long integer"); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
349 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
350 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
351 /************************************************************************ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
352 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
353 The PyHKEY object definition |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
354 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
355 ************************************************************************/ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
356 typedef struct { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
357 PyObject_VAR_HEAD |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
358 HKEY hkey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
359 } PyHKEYObject; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
360 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
361 #define PyHKEY_Check(op) ((op)->ob_type == &PyHKEY_Type) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
362 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
363 static char *failMsg = "bad operand type"; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
364 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
365 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
366 PyHKEY_unaryFailureFunc(PyObject *ob) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
367 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
368 PyErr_SetString(PyExc_TypeError, failMsg); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
370 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
372 PyHKEY_binaryFailureFunc(PyObject *ob1, PyObject *ob2) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
373 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
374 PyErr_SetString(PyExc_TypeError, failMsg); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
376 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
377 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
378 PyHKEY_ternaryFailureFunc(PyObject *ob1, PyObject *ob2, PyObject *ob3) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
379 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
380 PyErr_SetString(PyExc_TypeError, failMsg); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
381 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
382 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
383 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
384 static void |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
385 PyHKEY_deallocFunc(PyObject *ob) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
386 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
387 /* Can not call PyHKEY_Close, as the ob->tp_type |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
388 has already been cleared, thus causing the type |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
389 check to fail! |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
390 */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
391 PyHKEYObject *obkey = (PyHKEYObject *)ob; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
392 if (obkey->hkey) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
393 RegCloseKey((HKEY)obkey->hkey); |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
12076
diff
changeset
|
394 PyObject_DEL(ob); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
395 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
396 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
397 static int |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
398 PyHKEY_nonzeroFunc(PyObject *ob) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
399 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
400 return ((PyHKEYObject *)ob)->hkey != 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
401 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
402 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
403 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
404 PyHKEY_intFunc(PyObject *ob) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
405 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
406 PyHKEYObject *pyhkey = (PyHKEYObject *)ob; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
407 return PyLong_FromVoidPtr(pyhkey->hkey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
408 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
409 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
410 static int |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
411 PyHKEY_printFunc(PyObject *ob, FILE *fp, int flags) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
412 { |
|
50781
a858b61db324
#4807: Remove a wrong usage of wsprintf in the winreg module
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
413 PyHKEYObject *pyhkey = (PyHKEYObject *)ob; |
|
a858b61db324
#4807: Remove a wrong usage of wsprintf in the winreg module
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
414 fprintf(fp, "<PyHKEY at %p (%p)>", |
|
a858b61db324
#4807: Remove a wrong usage of wsprintf in the winreg module
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
415 ob, pyhkey->hkey); |
|
a858b61db324
#4807: Remove a wrong usage of wsprintf in the winreg module
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
416 return 0; |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
417 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
418 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
419 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
420 PyHKEY_strFunc(PyObject *ob) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
421 { |
|
50781
a858b61db324
#4807: Remove a wrong usage of wsprintf in the winreg module
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
422 PyHKEYObject *pyhkey = (PyHKEYObject *)ob; |
|
a858b61db324
#4807: Remove a wrong usage of wsprintf in the winreg module
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47527
diff
changeset
|
423 return PyString_FromFormat("<PyHKEY:%p>", pyhkey->hkey); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
424 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
425 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
426 static int |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
427 PyHKEY_compareFunc(PyObject *ob1, PyObject *ob2) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
428 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
429 PyHKEYObject *pyhkey1 = (PyHKEYObject *)ob1; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
430 PyHKEYObject *pyhkey2 = (PyHKEYObject *)ob2; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
431 return pyhkey1 == pyhkey2 ? 0 : |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
432 (pyhkey1 < pyhkey2 ? -1 : 1); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
433 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
434 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
435 static long |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
436 PyHKEY_hashFunc(PyObject *ob) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
437 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
438 /* Just use the address. |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
439 XXX - should we use the handle value? |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
440 */ |
|
13141
cca84745da3e
This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
13131
diff
changeset
|
441 return _Py_HashPointer(ob); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
442 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
443 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
444 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
445 static PyNumberMethods PyHKEY_NumberMethods = |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
446 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
447 PyHKEY_binaryFailureFunc, /* nb_add */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
448 PyHKEY_binaryFailureFunc, /* nb_subtract */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
449 PyHKEY_binaryFailureFunc, /* nb_multiply */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
450 PyHKEY_binaryFailureFunc, /* nb_divide */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
451 PyHKEY_binaryFailureFunc, /* nb_remainder */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
452 PyHKEY_binaryFailureFunc, /* nb_divmod */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
453 PyHKEY_ternaryFailureFunc, /* nb_power */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
454 PyHKEY_unaryFailureFunc, /* nb_negative */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
455 PyHKEY_unaryFailureFunc, /* nb_positive */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
456 PyHKEY_unaryFailureFunc, /* nb_absolute */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
457 PyHKEY_nonzeroFunc, /* nb_nonzero */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
458 PyHKEY_unaryFailureFunc, /* nb_invert */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
459 PyHKEY_binaryFailureFunc, /* nb_lshift */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
460 PyHKEY_binaryFailureFunc, /* nb_rshift */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
461 PyHKEY_binaryFailureFunc, /* nb_and */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
462 PyHKEY_binaryFailureFunc, /* nb_xor */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
463 PyHKEY_binaryFailureFunc, /* nb_or */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
464 0, /* nb_coerce (allowed to be zero) */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
465 PyHKEY_intFunc, /* nb_int */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
466 PyHKEY_unaryFailureFunc, /* nb_long */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
467 PyHKEY_unaryFailureFunc, /* nb_float */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
468 PyHKEY_unaryFailureFunc, /* nb_oct */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
469 PyHKEY_unaryFailureFunc, /* nb_hex */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
470 }; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
471 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
472 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
473 /* fwd declare __getattr__ */ |
|
36114
e9a10f74cf88
const poisoning, spreading to fix new const warnings
Tim Peters <tim.peters@gmail.com>
parents:
31046
diff
changeset
|
474 static PyObject *PyHKEY_getattr(PyObject *self, const char *name); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
475 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
476 /* The type itself */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
477 PyTypeObject PyHKEY_Type = |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
478 { |
|
42333
6620a510e9a9
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
Martin v. Löwis <martin@v.loewis.de>
parents:
41884
diff
changeset
|
479 PyVarObject_HEAD_INIT(0, 0) /* fill in type at module init */ |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
480 "PyHKEY", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
481 sizeof(PyHKEYObject), |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
482 0, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
483 PyHKEY_deallocFunc, /* tp_dealloc */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
484 PyHKEY_printFunc, /* tp_print */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
485 PyHKEY_getattr, /* tp_getattr */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
486 0, /* tp_setattr */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
487 PyHKEY_compareFunc, /* tp_compare */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
488 0, /* tp_repr */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
489 &PyHKEY_NumberMethods, /* tp_as_number */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
490 0, /* tp_as_sequence */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
491 0, /* tp_as_mapping */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
492 PyHKEY_hashFunc, /* tp_hash */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
493 0, /* tp_call */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
494 PyHKEY_strFunc, /* tp_str */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
495 0, /* tp_getattro */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
496 0, /* tp_setattro */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
497 0, /* tp_as_buffer */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
498 0, /* tp_flags */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
499 PyHKEY_doc, /* tp_doc */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
500 }; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
501 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
502 #define OFF(e) offsetof(PyHKEYObject, e) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
503 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
504 static struct memberlist PyHKEY_memberlist[] = { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
505 {"handle", T_INT, OFF(hkey)}, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
506 {NULL} /* Sentinel */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
507 }; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
508 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
509 /************************************************************************ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
510 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
511 The PyHKEY object methods |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
512 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
513 ************************************************************************/ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
514 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
515 PyHKEY_CloseMethod(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
516 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
517 if (!PyArg_ParseTuple(args, ":Close")) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
518 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
519 if (!PyHKEY_Close(self)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
520 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
521 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
522 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
523 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
524 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
525 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
526 PyHKEY_DetachMethod(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
527 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
528 void* ret; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
529 PyHKEYObject *pThis = (PyHKEYObject *)self; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
530 if (!PyArg_ParseTuple(args, ":Detach")) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
531 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
532 ret = (void*)pThis->hkey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
533 pThis->hkey = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
534 return PyLong_FromVoidPtr(ret); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
535 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
536 |
|
44598
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
537 static PyObject * |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
538 PyHKEY_Enter(PyObject *self) |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
539 { |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
540 Py_XINCREF(self); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
541 return self; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
542 } |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
543 |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
544 static PyObject * |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
545 PyHKEY_Exit(PyObject *self, PyObject *args) |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
546 { |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
547 if (!PyHKEY_Close(self)) |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
548 return NULL; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
549 Py_RETURN_NONE; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
550 } |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
551 |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
552 |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
553 static struct PyMethodDef PyHKEY_methods[] = { |
|
22705
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
554 {"Close", PyHKEY_CloseMethod, METH_VARARGS, PyHKEY_Close_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
555 {"Detach", PyHKEY_DetachMethod, METH_VARARGS, PyHKEY_Detach_doc}, |
|
44598
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
556 {"__enter__", (PyCFunction)PyHKEY_Enter, METH_NOARGS, NULL}, |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
557 {"__exit__", PyHKEY_Exit, METH_VARARGS, NULL}, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
558 {NULL} |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
559 }; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
560 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
561 /*static*/ PyObject * |
|
36114
e9a10f74cf88
const poisoning, spreading to fix new const warnings
Tim Peters <tim.peters@gmail.com>
parents:
31046
diff
changeset
|
562 PyHKEY_getattr(PyObject *self, const char *name) |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
563 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
564 PyObject *res; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
565 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
566 res = Py_FindMethod(PyHKEY_methods, self, name); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
567 if (res != NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
568 return res; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
569 PyErr_Clear(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
570 if (strcmp(name, "handle") == 0) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
571 return PyLong_FromVoidPtr(((PyHKEYObject *)self)->hkey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
572 return PyMember_Get((char *)self, PyHKEY_memberlist, name); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
573 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
574 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
575 /************************************************************************ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
576 The public PyHKEY API (well, not public yet :-) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
577 ************************************************************************/ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
578 PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
579 PyHKEY_New(HKEY hInit) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
580 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
581 PyHKEYObject *key = PyObject_NEW(PyHKEYObject, &PyHKEY_Type); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
582 if (key) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
583 key->hkey = hInit; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
584 return (PyObject *)key; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
585 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
586 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
587 BOOL |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
588 PyHKEY_Close(PyObject *ob_handle) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
589 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
590 LONG rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
591 PyHKEYObject *key; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
592 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
593 if (!PyHKEY_Check(ob_handle)) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
594 PyErr_SetString(PyExc_TypeError, "bad operand type"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
595 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
596 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
597 key = (PyHKEYObject *)ob_handle; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
598 rc = key->hkey ? RegCloseKey((HKEY)key->hkey) : ERROR_SUCCESS; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
599 key->hkey = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
600 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
601 PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
602 return rc == ERROR_SUCCESS; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
603 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
604 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
605 BOOL |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
606 PyHKEY_AsHKEY(PyObject *ob, HKEY *pHANDLE, BOOL bNoneOK) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
607 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
608 if (ob == Py_None) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
609 if (!bNoneOK) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
610 PyErr_SetString( |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
611 PyExc_TypeError, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
612 "None is not a valid HKEY in this context"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
613 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
614 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
615 *pHANDLE = (HKEY)0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
616 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
617 else if (PyHKEY_Check(ob)) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
618 PyHKEYObject *pH = (PyHKEYObject *)ob; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
619 *pHANDLE = pH->hkey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
620 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
621 else if (PyInt_Check(ob) || PyLong_Check(ob)) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
622 /* We also support integers */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
623 PyErr_Clear(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
624 *pHANDLE = (HKEY)PyLong_AsVoidPtr(ob); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
625 if (PyErr_Occurred()) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
626 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
627 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
628 else { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
629 PyErr_SetString( |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
630 PyExc_TypeError, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
631 "The object is not a PyHKEY object"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
632 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
633 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
634 return TRUE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
635 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
636 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
637 PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
638 PyHKEY_FromHKEY(HKEY h) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
639 { |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
12076
diff
changeset
|
640 PyHKEYObject *op; |
|
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
12076
diff
changeset
|
641 |
|
24898
a869d2de536f
Call me anal, but there was a particular phrase that was speading to
Guido van Rossum <guido@python.org>
parents:
24315
diff
changeset
|
642 /* Inline PyObject_New */ |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
12076
diff
changeset
|
643 op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject)); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
644 if (op == NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
645 return PyErr_NoMemory(); |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
12076
diff
changeset
|
646 PyObject_INIT(op, &PyHKEY_Type); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
647 op->hkey = h; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
648 return (PyObject *)op; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
649 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
650 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
651 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
652 /************************************************************************ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
653 The module methods |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
654 ************************************************************************/ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
655 BOOL |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
656 PyWinObject_CloseHKEY(PyObject *obHandle) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
657 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
658 BOOL ok; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
659 if (PyHKEY_Check(obHandle)) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
660 ok = PyHKEY_Close(obHandle); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
661 } |
|
13233
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
662 #if SIZEOF_LONG >= SIZEOF_HKEY |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
663 else if (PyInt_Check(obHandle)) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
664 long rc = RegCloseKey((HKEY)PyInt_AsLong(obHandle)); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
665 ok = (rc == ERROR_SUCCESS); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
666 if (!ok) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
667 PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
668 } |
|
13233
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
669 #else |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
670 else if (PyLong_Check(obHandle)) { |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
671 long rc = RegCloseKey((HKEY)PyLong_AsVoidPtr(obHandle)); |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
672 ok = (rc == ERROR_SUCCESS); |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
673 if (!ok) |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
674 PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
675 } |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
676 #endif |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
677 else { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
678 PyErr_SetString( |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
679 PyExc_TypeError, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
680 "A handle must be a HKEY object or an integer"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
681 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
682 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
683 return ok; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
684 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
685 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
686 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
687 /* |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
688 Private Helper functions for the registry interfaces |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
689 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
690 ** Note that fixupMultiSZ and countString have both had changes |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
691 ** made to support "incorrect strings". The registry specification |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
692 ** calls for strings to be terminated with 2 null bytes. It seems |
|
51775
af9b6c43804e
Issue #5341: Fix a variety of spelling errors.
Mark Dickinson <dickinsm@gmail.com>
parents:
50781
diff
changeset
|
693 ** some commercial packages install strings which don't conform, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
694 ** causing this code to fail - however, "regedit" etc still work |
|
51775
af9b6c43804e
Issue #5341: Fix a variety of spelling errors.
Mark Dickinson <dickinsm@gmail.com>
parents:
50781
diff
changeset
|
695 ** with these strings (ie only we don't!). |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
696 */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
697 static void |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
698 fixupMultiSZ(char **str, char *data, int len) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
699 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
700 char *P; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
701 int i; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
702 char *Q; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
703 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
704 Q = data + len; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
705 for (P = data, i = 0; P < Q && *P != '\0'; P++, i++) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
706 str[i] = P; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
707 for(; *P != '\0'; P++) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
708 ; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
709 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
710 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
711 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
712 static int |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
713 countStrings(char *data, int len) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
714 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
715 int strings; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
716 char *P; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
717 char *Q = data + len; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
718 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
719 for (P = data, strings = 0; P < Q && *P != '\0'; P++, strings++) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
720 for (; P < Q && *P != '\0'; P++) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
721 ; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
722 return strings; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
723 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
724 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
725 /* Convert PyObject into Registry data. |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
726 Allocates space as needed. */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
727 static BOOL |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
728 Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
729 { |
|
46062
09adff3d6691
Try to fix a bunch of compiler warnings on Win64.
Neal Norwitz <nnorwitz@gmail.com>
parents:
44598
diff
changeset
|
730 Py_ssize_t i,j; |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
731 switch (typ) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
732 case REG_DWORD: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
733 if (value != Py_None && !PyInt_Check(value)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
734 return FALSE; |
|
41525
b68272449df4
Merge change 54909 from release25-maint: Fix several minor issues discovered using code analysis in VisualStudio 2005 Team Edition
Kristján Valur Jónsson <kristjan@ccpgames.com>
parents:
39157
diff
changeset
|
735 *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
736 if (*retDataBuf==NULL){ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
737 PyErr_NoMemory(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
738 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
739 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
740 *retDataSize = sizeof(DWORD); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
741 if (value == Py_None) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
742 DWORD zero = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
743 memcpy(*retDataBuf, &zero, sizeof(DWORD)); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
744 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
745 else |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
746 memcpy(*retDataBuf, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
747 &PyInt_AS_LONG((PyIntObject *)value), |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
748 sizeof(DWORD)); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
749 break; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
750 case REG_SZ: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
751 case REG_EXPAND_SZ: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
752 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
753 int need_decref = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
754 if (value == Py_None) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
755 *retDataSize = 1; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
756 else { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
757 if (PyUnicode_Check(value)) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
758 value = PyUnicode_AsEncodedString( |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
759 value, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
760 "mbcs", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
761 NULL); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
762 if (value==NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
763 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
764 need_decref = 1; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
765 } |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
766 if (!PyString_Check(value)) |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
767 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
768 *retDataSize = 1 + strlen( |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
769 PyString_AS_STRING( |
|
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
770 (PyStringObject *)value)); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
771 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
772 *retDataBuf = (BYTE *)PyMem_NEW(DWORD, *retDataSize); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
773 if (*retDataBuf==NULL){ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
774 PyErr_NoMemory(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
775 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
776 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
777 if (value == Py_None) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
778 strcpy((char *)*retDataBuf, ""); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
779 else |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
780 strcpy((char *)*retDataBuf, |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
781 PyString_AS_STRING( |
|
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
782 (PyStringObject *)value)); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
783 if (need_decref) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
784 Py_DECREF(value); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
785 break; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
786 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
787 case REG_MULTI_SZ: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
788 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
789 DWORD size = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
790 char *P; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
791 PyObject **obs = NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
792 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
793 if (value == Py_None) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
794 i = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
795 else { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
796 if (!PyList_Check(value)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
797 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
798 i = PyList_Size(value); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
799 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
800 obs = malloc(sizeof(PyObject *) * i); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
801 memset(obs, 0, sizeof(PyObject *) * i); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
802 for (j = 0; j < i; j++) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
803 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
804 PyObject *t; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
805 t = PyList_GET_ITEM( |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
806 (PyListObject *)value,j); |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
807 if (PyString_Check(t)) { |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
808 obs[j] = t; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
809 Py_INCREF(t); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
810 } else if (PyUnicode_Check(t)) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
811 obs[j] = PyUnicode_AsEncodedString( |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
812 t, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
813 "mbcs", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
814 NULL); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
815 if (obs[j]==NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
816 goto reg_multi_fail; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
817 } else |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
818 goto reg_multi_fail; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
819 size += 1 + strlen( |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
820 PyString_AS_STRING( |
|
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
821 (PyStringObject *)obs[j])); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
822 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
823 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
824 *retDataSize = size + 1; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
825 *retDataBuf = (BYTE *)PyMem_NEW(char, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
826 *retDataSize); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
827 if (*retDataBuf==NULL){ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
828 PyErr_NoMemory(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
829 goto reg_multi_fail; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
830 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
831 P = (char *)*retDataBuf; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
832 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
833 for (j = 0; j < i; j++) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
834 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
835 PyObject *t; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
836 t = obs[j]; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
837 strcpy(P, |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
838 PyString_AS_STRING( |
|
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
839 (PyStringObject *)t)); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
840 P += 1 + strlen( |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
841 PyString_AS_STRING( |
|
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
842 (PyStringObject *)t)); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
843 Py_DECREF(obs[j]); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
844 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
845 /* And doubly-terminate the list... */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
846 *P = '\0'; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
847 free(obs); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
848 break; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
849 reg_multi_fail: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
850 if (obs) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
851 for (j = 0; j < i; j++) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
852 Py_XDECREF(obs[j]); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
853 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
854 free(obs); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
855 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
856 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
857 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
858 case REG_BINARY: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
859 /* ALSO handle ALL unknown data types here. Even if we can't |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
860 support it natively, we should handle the bits. */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
861 default: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
862 if (value == Py_None) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
863 *retDataSize = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
864 else { |
|
13736
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
865 void *src_buf; |
|
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
866 PyBufferProcs *pb = value->ob_type->tp_as_buffer; |
|
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
867 if (pb==NULL) { |
|
36586
2475fe95782d
PyEnumKey(): Stop including the trailing NUL byte
Tim Peters <tim.peters@gmail.com>
parents:
36585
diff
changeset
|
868 PyErr_Format(PyExc_TypeError, |
|
13736
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
869 "Objects of type '%s' can not " |
|
36586
2475fe95782d
PyEnumKey(): Stop including the trailing NUL byte
Tim Peters <tim.peters@gmail.com>
parents:
36585
diff
changeset
|
870 "be used as binary registry values", |
|
13736
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
871 value->ob_type->tp_name); |
|
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
872 return FALSE; |
|
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
873 } |
|
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
874 *retDataSize = (*pb->bf_getreadbuffer)(value, 0, &src_buf); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
875 *retDataBuf = (BYTE *)PyMem_NEW(char, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
876 *retDataSize); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
877 if (*retDataBuf==NULL){ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
878 PyErr_NoMemory(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
879 return FALSE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
880 } |
|
13736
32ce254f3bea
Allow any object supporting the buffer protocol to be written as a binary object.
Mark Hammond <mhammond@skippinet.com.au>
parents:
13620
diff
changeset
|
881 memcpy(*retDataBuf, src_buf, *retDataSize); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
882 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
883 break; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
884 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
885 return TRUE; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
886 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
887 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
888 /* Convert Registry data into PyObject*/ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
889 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
890 Reg2Py(char *retDataBuf, DWORD retDataSize, DWORD typ) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
891 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
892 PyObject *obData; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
893 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
894 switch (typ) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
895 case REG_DWORD: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
896 if (retDataSize == 0) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
897 obData = Py_BuildValue("i", 0); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
898 else |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
899 obData = Py_BuildValue("i", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
900 *(int *)retDataBuf); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
901 break; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
902 case REG_SZ: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
903 case REG_EXPAND_SZ: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
904 /* retDataBuf may or may not have a trailing NULL in |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
905 the buffer. */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
906 if (retDataSize && retDataBuf[retDataSize-1] == '\0') |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
907 --retDataSize; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
908 if (retDataSize ==0) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
909 retDataBuf = ""; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
910 obData = PyUnicode_DecodeMBCS(retDataBuf, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
911 retDataSize, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
912 NULL); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
913 break; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
914 case REG_MULTI_SZ: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
915 if (retDataSize == 0) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
916 obData = PyList_New(0); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
917 else |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
918 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
919 int index = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
920 int s = countStrings(retDataBuf, retDataSize); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
921 char **str = (char **)malloc(sizeof(char *)*s); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
922 if (str == NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
923 return PyErr_NoMemory(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
924 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
925 fixupMultiSZ(str, retDataBuf, retDataSize); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
926 obData = PyList_New(s); |
|
13233
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
927 if (obData == NULL) |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
928 return NULL; |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
929 for (index = 0; index < s; index++) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
930 { |
|
13233
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
931 size_t len = _mbstrlen(str[index]); |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
932 if (len > INT_MAX) { |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
933 PyErr_SetString(PyExc_OverflowError, |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
934 "registry string is too long for a Python string"); |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
935 Py_DECREF(obData); |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
936 return NULL; |
|
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
937 } |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
938 PyList_SetItem(obData, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
939 index, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
940 PyUnicode_DecodeMBCS( |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
941 (const char *)str[index], |
|
13233
86c9f691f379
[*** Not tested as I don't have Windows running right now! ***]
Fred Drake <fdrake@acm.org>
parents:
13141
diff
changeset
|
942 (int)len, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
943 NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
944 ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
945 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
946 free(str); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
947 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
948 break; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
949 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
950 case REG_BINARY: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
951 /* ALSO handle ALL unknown data types here. Even if we can't |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
952 support it natively, we should handle the bits. */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
953 default: |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
954 if (retDataSize == 0) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
955 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
956 obData = Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
957 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
958 else |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
959 obData = Py_BuildValue("s#", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
960 (char *)retDataBuf, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
961 retDataSize); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
962 break; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
963 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
964 if (obData == NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
965 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
966 else |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
967 return obData; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
968 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
969 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
970 /* The Python methods */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
971 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
972 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
973 PyCloseKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
974 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
975 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
976 if (!PyArg_ParseTuple(args, "O:CloseKey", &obKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
977 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
978 if (!PyHKEY_Close(obKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
979 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
980 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
981 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
982 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
983 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
984 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
985 PyConnectRegistry(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
986 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
987 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
988 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
989 char *szCompName = NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
990 HKEY retKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
991 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
992 if (!PyArg_ParseTuple(args, "zO:ConnectRegistry", &szCompName, &obKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
993 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
994 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
995 return NULL; |
|
39157
832d5a34130f
Patch #1448199: Release GIL around ConnectRegistry.
Martin v. Löwis <martin@v.loewis.de>
parents:
36586
diff
changeset
|
996 Py_BEGIN_ALLOW_THREADS |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
997 rc = RegConnectRegistry(szCompName, hKey, &retKey); |
|
39157
832d5a34130f
Patch #1448199: Release GIL around ConnectRegistry.
Martin v. Löwis <martin@v.loewis.de>
parents:
36586
diff
changeset
|
998 Py_END_ALLOW_THREADS |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
999 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1000 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1001 "ConnectRegistry"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1002 return PyHKEY_FromHKEY(retKey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1003 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1004 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1005 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1006 PyCreateKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1007 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1008 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1009 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1010 char *subKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1011 HKEY retKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1012 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1013 if (!PyArg_ParseTuple(args, "Oz:CreateKey", &obKey, &subKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1014 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1015 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1016 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1017 rc = RegCreateKey(hKey, subKey, &retKey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1018 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1019 return PyErr_SetFromWindowsErrWithFunction(rc, "CreateKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1020 return PyHKEY_FromHKEY(retKey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1021 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1022 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1023 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1024 PyDeleteKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1025 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1026 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1027 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1028 char *subKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1029 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1030 if (!PyArg_ParseTuple(args, "Os:DeleteKey", &obKey, &subKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1031 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1032 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1033 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1034 rc = RegDeleteKey(hKey, subKey ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1035 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1036 return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1037 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1038 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1039 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1040 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1041 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1042 PyDeleteValue(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1043 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1044 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1045 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1046 char *subKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1047 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1048 if (!PyArg_ParseTuple(args, "Oz:DeleteValue", &obKey, &subKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1049 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1050 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1051 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1052 Py_BEGIN_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1053 rc = RegDeleteValue(hKey, subKey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1054 Py_END_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1055 if (rc !=ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1056 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1057 "RegDeleteValue"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1058 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1059 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1060 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1061 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1062 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1063 PyEnumKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1064 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1065 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1066 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1067 int index; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1068 long rc; |
| 31046 | 1069 PyObject *retStr; |
|
36578
81ffdeea1d06
Patch #977553: speed up RegEnumKey call
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
1070 char tmpbuf[256]; /* max key name length is 255 */ |
|
36579
02a0eb1a2b21
Add sizeof() instead of hardcoding variable length
Georg Brandl <georg@python.org>
parents:
36578
diff
changeset
|
1071 DWORD len = sizeof(tmpbuf); /* includes NULL terminator */ |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1072 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1073 if (!PyArg_ParseTuple(args, "Oi:EnumKey", &obKey, &index)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1074 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1075 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1076 return NULL; |
|
36586
2475fe95782d
PyEnumKey(): Stop including the trailing NUL byte
Tim Peters <tim.peters@gmail.com>
parents:
36585
diff
changeset
|
1077 |
|
36578
81ffdeea1d06
Patch #977553: speed up RegEnumKey call
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
1078 Py_BEGIN_ALLOW_THREADS |
|
81ffdeea1d06
Patch #977553: speed up RegEnumKey call
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
1079 rc = RegEnumKeyEx(hKey, index, tmpbuf, &len, NULL, NULL, NULL, NULL); |
|
81ffdeea1d06
Patch #977553: speed up RegEnumKey call
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
1080 Py_END_ALLOW_THREADS |
|
81ffdeea1d06
Patch #977553: speed up RegEnumKey call
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
1081 if (rc != ERROR_SUCCESS) |
|
81ffdeea1d06
Patch #977553: speed up RegEnumKey call
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
1082 return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx"); |
|
36586
2475fe95782d
PyEnumKey(): Stop including the trailing NUL byte
Tim Peters <tim.peters@gmail.com>
parents:
36585
diff
changeset
|
1083 |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
1084 retStr = PyString_FromStringAndSize(tmpbuf, len); |
|
36578
81ffdeea1d06
Patch #977553: speed up RegEnumKey call
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
1085 return retStr; /* can be NULL */ |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1086 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1087 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1088 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1089 PyEnumValue(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1090 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1091 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1092 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1093 int index; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1094 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1095 char *retValueBuf; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1096 char *retDataBuf; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1097 DWORD retValueSize; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1098 DWORD retDataSize; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1099 DWORD typ; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1100 PyObject *obData; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1101 PyObject *retVal; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1102 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1103 if (!PyArg_ParseTuple(args, "Oi:EnumValue", &obKey, &index)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1104 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1105 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1106 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1107 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1108 if ((rc = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1109 NULL, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1110 &retValueSize, &retDataSize, NULL, NULL)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1111 != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1112 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1113 "RegQueryInfoKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1114 ++retValueSize; /* include null terminators */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1115 ++retDataSize; |
| 31046 | 1116 retValueBuf = (char *)PyMem_Malloc(retValueSize); |
| 1117 if (retValueBuf == NULL) | |
| 1118 return PyErr_NoMemory(); | |
| 1119 retDataBuf = (char *)PyMem_Malloc(retDataSize); | |
| 1120 if (retDataBuf == NULL) { | |
| 1121 PyMem_Free(retValueBuf); | |
| 1122 return PyErr_NoMemory(); | |
| 1123 } | |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1124 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1125 Py_BEGIN_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1126 rc = RegEnumValue(hKey, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1127 index, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1128 retValueBuf, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1129 &retValueSize, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1130 NULL, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1131 &typ, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1132 (BYTE *)retDataBuf, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1133 &retDataSize); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1134 Py_END_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1135 |
| 31046 | 1136 if (rc != ERROR_SUCCESS) { |
| 1137 retVal = PyErr_SetFromWindowsErrWithFunction(rc, | |
| 1138 "PyRegEnumValue"); | |
| 1139 goto fail; | |
| 1140 } | |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1141 obData = Reg2Py(retDataBuf, retDataSize, typ); |
| 31046 | 1142 if (obData == NULL) { |
| 1143 retVal = NULL; | |
| 1144 goto fail; | |
| 1145 } | |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1146 retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1147 Py_DECREF(obData); |
| 31046 | 1148 fail: |
| 1149 PyMem_Free(retValueBuf); | |
| 1150 PyMem_Free(retDataBuf); | |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1151 return retVal; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1152 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1153 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1154 static PyObject * |
|
44598
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1155 PyExpandEnvironmentStrings(PyObject *self, PyObject *args) |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1156 { |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1157 Py_UNICODE *retValue = NULL; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1158 Py_UNICODE *src; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1159 DWORD retValueSize; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1160 DWORD rc; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1161 PyObject *o; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1162 |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1163 if (!PyArg_ParseTuple(args, "u:ExpandEnvironmentStrings", &src)) |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1164 return NULL; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1165 |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1166 retValueSize = ExpandEnvironmentStringsW(src, retValue, 0); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1167 if (retValueSize == 0) { |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1168 return PyErr_SetFromWindowsErrWithFunction(retValueSize, |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1169 "ExpandEnvironmentStrings"); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1170 } |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1171 retValue = (Py_UNICODE *)PyMem_Malloc(retValueSize * sizeof(Py_UNICODE)); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1172 if (retValue == NULL) { |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1173 return PyErr_NoMemory(); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1174 } |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1175 |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1176 rc = ExpandEnvironmentStringsW(src, retValue, retValueSize); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1177 if (rc == 0) { |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1178 PyMem_Free(retValue); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1179 return PyErr_SetFromWindowsErrWithFunction(retValueSize, |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1180 "ExpandEnvironmentStrings"); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1181 } |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1182 o = PyUnicode_FromUnicode(retValue, wcslen(retValue)); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1183 PyMem_Free(retValue); |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1184 return o; |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1185 } |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1186 |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1187 static PyObject * |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1188 PyFlushKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1189 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1190 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1191 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1192 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1193 if (!PyArg_ParseTuple(args, "O:FlushKey", &obKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1194 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1195 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1196 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1197 Py_BEGIN_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1198 rc = RegFlushKey(hKey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1199 Py_END_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1200 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1201 return PyErr_SetFromWindowsErrWithFunction(rc, "RegFlushKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1202 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1203 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1204 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1205 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1206 PyLoadKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1207 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1208 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1209 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1210 char *subKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1211 char *fileName; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1212 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1213 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1214 if (!PyArg_ParseTuple(args, "Oss:LoadKey", &obKey, &subKey, &fileName)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1215 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1216 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1217 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1218 Py_BEGIN_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1219 rc = RegLoadKey(hKey, subKey, fileName ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1220 Py_END_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1221 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1222 return PyErr_SetFromWindowsErrWithFunction(rc, "RegLoadKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1223 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1224 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1225 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1226 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1227 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1228 PyOpenKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1229 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1230 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1231 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1232 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1233 char *subKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1234 int res = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1235 HKEY retKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1236 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1237 REGSAM sam = KEY_READ; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1238 if (!PyArg_ParseTuple(args, "Oz|ii:OpenKey", &obKey, &subKey, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1239 &res, &sam)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1240 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1241 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1242 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1243 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1244 Py_BEGIN_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1245 rc = RegOpenKeyEx(hKey, subKey, res, sam, &retKey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1246 Py_END_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1247 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1248 return PyErr_SetFromWindowsErrWithFunction(rc, "RegOpenKeyEx"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1249 return PyHKEY_FromHKEY(retKey); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1250 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1251 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1252 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1253 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1254 PyQueryInfoKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1255 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1256 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1257 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1258 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1259 DWORD nSubKeys, nValues; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1260 FILETIME ft; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1261 LARGE_INTEGER li; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1262 PyObject *l; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1263 PyObject *ret; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1264 if (!PyArg_ParseTuple(args, "O:QueryInfoKey", &obKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1265 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1266 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1267 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1268 if ((rc = RegQueryInfoKey(hKey, NULL, NULL, 0, &nSubKeys, NULL, NULL, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1269 &nValues, NULL, NULL, NULL, &ft)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1270 != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1271 return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1272 li.LowPart = ft.dwLowDateTime; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1273 li.HighPart = ft.dwHighDateTime; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1274 l = PyLong_FromLongLong(li.QuadPart); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1275 if (l == NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1276 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1277 ret = Py_BuildValue("iiO", nSubKeys, nValues, l); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1278 Py_DECREF(l); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1279 return ret; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1280 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1281 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1282 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1283 PyQueryValue(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1284 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1285 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1286 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1287 char *subKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1288 long rc; |
| 31046 | 1289 PyObject *retStr; |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1290 char *retBuf; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1291 long bufSize = 0; |
| 31046 | 1292 |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1293 if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1294 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1295 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1296 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1297 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1298 if ((rc = RegQueryValue(hKey, subKey, NULL, &bufSize)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1299 != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1300 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1301 "RegQueryValue"); |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
1302 retStr = PyString_FromStringAndSize(NULL, bufSize); |
| 31046 | 1303 if (retStr == NULL) |
| 1304 return NULL; | |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
1305 retBuf = PyString_AS_STRING(retStr); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1306 if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize)) |
| 31046 | 1307 != ERROR_SUCCESS) { |
| 1308 Py_DECREF(retStr); | |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1309 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1310 "RegQueryValue"); |
| 31046 | 1311 } |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
1312 _PyString_Resize(&retStr, strlen(retBuf)); |
| 31046 | 1313 return retStr; |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1314 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1315 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1316 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1317 PyQueryValueEx(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1318 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1319 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1320 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1321 char *valueName; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1322 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1323 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1324 char *retBuf; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1325 DWORD bufSize = 0; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1326 DWORD typ; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1327 PyObject *obData; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1328 PyObject *result; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1329 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1330 if (!PyArg_ParseTuple(args, "Oz:QueryValueEx", &obKey, &valueName)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1331 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1332 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1333 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1334 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1335 if ((rc = RegQueryValueEx(hKey, valueName, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1336 NULL, NULL, NULL, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1337 &bufSize)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1338 != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1339 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1340 "RegQueryValueEx"); |
| 31046 | 1341 retBuf = (char *)PyMem_Malloc(bufSize); |
| 1342 if (retBuf == NULL) | |
| 1343 return PyErr_NoMemory(); | |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1344 if ((rc = RegQueryValueEx(hKey, valueName, NULL, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1345 &typ, (BYTE *)retBuf, &bufSize)) |
| 31046 | 1346 != ERROR_SUCCESS) { |
| 1347 PyMem_Free(retBuf); | |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1348 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1349 "RegQueryValueEx"); |
| 31046 | 1350 } |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1351 obData = Reg2Py(retBuf, bufSize, typ); |
| 31046 | 1352 PyMem_Free((void *)retBuf); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1353 if (obData == NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1354 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1355 result = Py_BuildValue("Oi", obData, typ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1356 Py_DECREF(obData); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1357 return result; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1358 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1359 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1360 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1361 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1362 PySaveKey(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1363 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1364 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1365 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1366 char *fileName; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1367 LPSECURITY_ATTRIBUTES pSA = NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1368 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1369 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1370 if (!PyArg_ParseTuple(args, "Os:SaveKey", &obKey, &fileName)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1371 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1372 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1373 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1374 /* One day we may get security into the core? |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1375 if (!PyWinObject_AsSECURITY_ATTRIBUTES(obSA, &pSA, TRUE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1376 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1377 */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1378 Py_BEGIN_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1379 rc = RegSaveKey(hKey, fileName, pSA ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1380 Py_END_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1381 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1382 return PyErr_SetFromWindowsErrWithFunction(rc, "RegSaveKey"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1383 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1384 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1385 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1386 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1387 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1388 PySetValue(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1389 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1390 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1391 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1392 char *subKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1393 char *str; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1394 DWORD typ; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1395 DWORD len; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1396 long rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1397 PyObject *obStrVal; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1398 PyObject *obSubKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1399 if (!PyArg_ParseTuple(args, "OOiO:SetValue", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1400 &obKey, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1401 &obSubKey, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1402 &typ, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1403 &obStrVal)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1404 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1405 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1406 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1407 if (typ != REG_SZ) { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1408 PyErr_SetString(PyExc_TypeError, |
|
26735
16aff7077e4b
Fix an error message in the _winreg module. The error message referred
Thomas Heller <theller@ctypes.org>
parents:
24898
diff
changeset
|
1409 "Type must be _winreg.REG_SZ"); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1410 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1411 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1412 /* XXX - need Unicode support */ |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
1413 str = PyString_AsString(obStrVal); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1414 if (str == NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1415 return NULL; |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
1416 len = PyString_Size(obStrVal); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1417 if (obSubKey == Py_None) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1418 subKey = NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1419 else { |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
1420 subKey = PyString_AsString(obSubKey); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1421 if (subKey == NULL) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1422 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1423 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1424 Py_BEGIN_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1425 rc = RegSetValue(hKey, subKey, REG_SZ, str, len+1); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1426 Py_END_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1427 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1428 return PyErr_SetFromWindowsErrWithFunction(rc, "RegSetValue"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1429 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1430 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1431 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1432 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1433 static PyObject * |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1434 PySetValueEx(PyObject *self, PyObject *args) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1435 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1436 HKEY hKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1437 PyObject *obKey; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1438 char *valueName; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1439 PyObject *obRes; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1440 PyObject *value; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1441 BYTE *data; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1442 DWORD len; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1443 DWORD typ; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1444 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1445 LONG rc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1446 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1447 if (!PyArg_ParseTuple(args, "OzOiO:SetValueEx", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1448 &obKey, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1449 &valueName, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1450 &obRes, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1451 &typ, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1452 &value)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1453 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1454 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1455 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1456 if (!Py2Reg(value, typ, &data, &len)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1457 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1458 if (!PyErr_Occurred()) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1459 PyErr_SetString(PyExc_ValueError, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1460 "Could not convert the data to the specified type."); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1461 return NULL; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1462 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1463 Py_BEGIN_ALLOW_THREADS |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1464 rc = RegSetValueEx(hKey, valueName, 0, typ, data, len); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1465 Py_END_ALLOW_THREADS |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
12076
diff
changeset
|
1466 PyMem_DEL(data); |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1467 if (rc != ERROR_SUCCESS) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1468 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1469 "RegSetValueEx"); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1470 Py_INCREF(Py_None); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1471 return Py_None; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1472 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1473 |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1474 static PyObject * |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1475 PyDisableReflectionKey(PyObject *self, PyObject *args) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1476 { |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1477 HKEY hKey; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1478 PyObject *obKey; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1479 HMODULE hMod; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1480 typedef LONG (WINAPI *RDRKFunc)(HKEY); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1481 RDRKFunc pfn = NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1482 LONG rc; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1483 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1484 if (!PyArg_ParseTuple(args, "O:DisableReflectionKey", &obKey)) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1485 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1486 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1487 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1488 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1489 // Only available on 64bit platforms, so we must load it |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1490 // dynamically. |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1491 hMod = GetModuleHandle("advapi32.dll"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1492 if (hMod) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1493 pfn = (RDRKFunc)GetProcAddress(hMod, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1494 "RegDisableReflectionKey"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1495 if (!pfn) { |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1496 PyErr_SetString(PyExc_NotImplementedError, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1497 "not implemented on this platform"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1498 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1499 } |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1500 Py_BEGIN_ALLOW_THREADS |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1501 rc = (*pfn)(hKey); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1502 Py_END_ALLOW_THREADS |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1503 if (rc != ERROR_SUCCESS) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1504 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1505 "RegDisableReflectionKey"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1506 Py_INCREF(Py_None); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1507 return Py_None; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1508 } |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1509 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1510 static PyObject * |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1511 PyEnableReflectionKey(PyObject *self, PyObject *args) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1512 { |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1513 HKEY hKey; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1514 PyObject *obKey; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1515 HMODULE hMod; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1516 typedef LONG (WINAPI *RERKFunc)(HKEY); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1517 RERKFunc pfn = NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1518 LONG rc; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1519 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1520 if (!PyArg_ParseTuple(args, "O:EnableReflectionKey", &obKey)) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1521 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1522 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1523 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1524 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1525 // Only available on 64bit platforms, so we must load it |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1526 // dynamically. |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1527 hMod = GetModuleHandle("advapi32.dll"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1528 if (hMod) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1529 pfn = (RERKFunc)GetProcAddress(hMod, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1530 "RegEnableReflectionKey"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1531 if (!pfn) { |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1532 PyErr_SetString(PyExc_NotImplementedError, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1533 "not implemented on this platform"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1534 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1535 } |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1536 Py_BEGIN_ALLOW_THREADS |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1537 rc = (*pfn)(hKey); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1538 Py_END_ALLOW_THREADS |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1539 if (rc != ERROR_SUCCESS) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1540 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1541 "RegEnableReflectionKey"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1542 Py_INCREF(Py_None); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1543 return Py_None; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1544 } |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1545 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1546 static PyObject * |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1547 PyQueryReflectionKey(PyObject *self, PyObject *args) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1548 { |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1549 HKEY hKey; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1550 PyObject *obKey; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1551 HMODULE hMod; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1552 typedef LONG (WINAPI *RQRKFunc)(HKEY, BOOL *); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1553 RQRKFunc pfn = NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1554 BOOL result; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1555 LONG rc; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1556 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1557 if (!PyArg_ParseTuple(args, "O:QueryReflectionKey", &obKey)) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1558 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1559 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1560 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1561 |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1562 // Only available on 64bit platforms, so we must load it |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1563 // dynamically. |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1564 hMod = GetModuleHandle("advapi32.dll"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1565 if (hMod) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1566 pfn = (RQRKFunc)GetProcAddress(hMod, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1567 "RegQueryReflectionKey"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1568 if (!pfn) { |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1569 PyErr_SetString(PyExc_NotImplementedError, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1570 "not implemented on this platform"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1571 return NULL; |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1572 } |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1573 Py_BEGIN_ALLOW_THREADS |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1574 rc = (*pfn)(hKey, &result); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1575 Py_END_ALLOW_THREADS |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1576 if (rc != ERROR_SUCCESS) |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1577 return PyErr_SetFromWindowsErrWithFunction(rc, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1578 "RegQueryReflectionKey"); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1579 return PyBool_FromLong(rc); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1580 } |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1581 |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1582 static struct PyMethodDef winreg_methods[] = { |
|
22705
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1583 {"CloseKey", PyCloseKey, METH_VARARGS, CloseKey_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1584 {"ConnectRegistry", PyConnectRegistry, METH_VARARGS, ConnectRegistry_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1585 {"CreateKey", PyCreateKey, METH_VARARGS, CreateKey_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1586 {"DeleteKey", PyDeleteKey, METH_VARARGS, DeleteKey_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1587 {"DeleteValue", PyDeleteValue, METH_VARARGS, DeleteValue_doc}, |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1588 {"DisableReflectionKey", PyDisableReflectionKey, METH_VARARGS, DisableReflectionKey_doc}, |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1589 {"EnableReflectionKey", PyEnableReflectionKey, METH_VARARGS, EnableReflectionKey_doc}, |
|
22705
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1590 {"EnumKey", PyEnumKey, METH_VARARGS, EnumKey_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1591 {"EnumValue", PyEnumValue, METH_VARARGS, EnumValue_doc}, |
|
44598
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1592 {"ExpandEnvironmentStrings", PyExpandEnvironmentStrings, METH_VARARGS, |
|
088b5077c900
Added __enter__ and __exit__ functions to HKEY object
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
1593 ExpandEnvironmentStrings_doc }, |
|
22705
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1594 {"FlushKey", PyFlushKey, METH_VARARGS, FlushKey_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1595 {"LoadKey", PyLoadKey, METH_VARARGS, LoadKey_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1596 {"OpenKey", PyOpenKey, METH_VARARGS, OpenKey_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1597 {"OpenKeyEx", PyOpenKey, METH_VARARGS, OpenKeyEx_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1598 {"QueryValue", PyQueryValue, METH_VARARGS, QueryValue_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1599 {"QueryValueEx", PyQueryValueEx, METH_VARARGS, QueryValueEx_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1600 {"QueryInfoKey", PyQueryInfoKey, METH_VARARGS, QueryInfoKey_doc}, |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1601 {"QueryReflectionKey",PyQueryReflectionKey,METH_VARARGS, QueryReflectionKey_doc}, |
|
22705
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1602 {"SaveKey", PySaveKey, METH_VARARGS, SaveKey_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1603 {"SetValue", PySetValue, METH_VARARGS, SetValue_doc}, |
|
8703d2052339
Use symbolic METH_VARARGS instead of 1 for ml_flags
Neal Norwitz <nnorwitz@gmail.com>
parents:
13736
diff
changeset
|
1604 {"SetValueEx", PySetValueEx, METH_VARARGS, SetValueEx_doc}, |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1605 NULL, |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1606 }; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1607 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1608 static void |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1609 insint(PyObject * d, char * name, long value) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1610 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1611 PyObject *v = PyInt_FromLong(value); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1612 if (!v || PyDict_SetItemString(d, name, v)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1613 PyErr_Clear(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1614 Py_XDECREF(v); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1615 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1616 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1617 #define ADD_INT(val) insint(d, #val, val) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1618 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1619 static void |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1620 inskey(PyObject * d, char * name, HKEY key) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1621 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1622 PyObject *v = PyLong_FromVoidPtr(key); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1623 if (!v || PyDict_SetItemString(d, name, v)) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1624 PyErr_Clear(); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1625 Py_XDECREF(v); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1626 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1627 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1628 #define ADD_KEY(val) inskey(d, #val, val) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1629 |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23832
diff
changeset
|
1630 PyMODINIT_FUNC init_winreg(void) |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1631 { |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1632 PyObject *m, *d; |
|
13131
05cc45d57a7f
Update the module name to _winreg, pending checkin of Paul Prescod's
Fred Drake <fdrake@acm.org>
parents:
12901
diff
changeset
|
1633 m = Py_InitModule3("_winreg", winreg_methods, module_doc); |
|
36324
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36114
diff
changeset
|
1634 if (m == NULL) |
|
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36114
diff
changeset
|
1635 return; |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1636 d = PyModule_GetDict(m); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1637 PyHKEY_Type.ob_type = &PyType_Type; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1638 PyHKEY_Type.tp_doc = PyHKEY_doc; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1639 Py_INCREF(&PyHKEY_Type); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1640 if (PyDict_SetItemString(d, "HKEYType", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1641 (PyObject *)&PyHKEY_Type) != 0) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1642 return; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1643 Py_INCREF(PyExc_WindowsError); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1644 if (PyDict_SetItemString(d, "error", |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1645 PyExc_WindowsError) != 0) |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1646 return; |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1647 |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1648 /* Add the relevant constants */ |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1649 ADD_KEY(HKEY_CLASSES_ROOT); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1650 ADD_KEY(HKEY_CURRENT_USER); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1651 ADD_KEY(HKEY_LOCAL_MACHINE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1652 ADD_KEY(HKEY_USERS); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1653 ADD_KEY(HKEY_PERFORMANCE_DATA); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1654 #ifdef HKEY_CURRENT_CONFIG |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1655 ADD_KEY(HKEY_CURRENT_CONFIG); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1656 #endif |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1657 #ifdef HKEY_DYN_DATA |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1658 ADD_KEY(HKEY_DYN_DATA); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1659 #endif |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1660 ADD_INT(KEY_QUERY_VALUE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1661 ADD_INT(KEY_SET_VALUE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1662 ADD_INT(KEY_CREATE_SUB_KEY); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1663 ADD_INT(KEY_ENUMERATE_SUB_KEYS); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1664 ADD_INT(KEY_NOTIFY); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1665 ADD_INT(KEY_CREATE_LINK); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1666 ADD_INT(KEY_READ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1667 ADD_INT(KEY_WRITE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1668 ADD_INT(KEY_EXECUTE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1669 ADD_INT(KEY_ALL_ACCESS); |
|
46320
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1670 #ifdef KEY_WOW64_64KEY |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1671 ADD_INT(KEY_WOW64_64KEY); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1672 #endif |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1673 #ifdef KEY_WOW64_32KEY |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1674 ADD_INT(KEY_WOW64_32KEY); |
|
012d97bbeeaf
From issue 1753245 - better _winreg support for x64.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46062
diff
changeset
|
1675 #endif |
|
12076
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1676 ADD_INT(REG_OPTION_RESERVED); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1677 ADD_INT(REG_OPTION_NON_VOLATILE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1678 ADD_INT(REG_OPTION_VOLATILE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1679 ADD_INT(REG_OPTION_CREATE_LINK); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1680 ADD_INT(REG_OPTION_BACKUP_RESTORE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1681 ADD_INT(REG_OPTION_OPEN_LINK); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1682 ADD_INT(REG_LEGAL_OPTION); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1683 ADD_INT(REG_CREATED_NEW_KEY); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1684 ADD_INT(REG_OPENED_EXISTING_KEY); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1685 ADD_INT(REG_WHOLE_HIVE_VOLATILE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1686 ADD_INT(REG_REFRESH_HIVE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1687 ADD_INT(REG_NO_LAZY_FLUSH); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1688 ADD_INT(REG_NOTIFY_CHANGE_NAME); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1689 ADD_INT(REG_NOTIFY_CHANGE_ATTRIBUTES); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1690 ADD_INT(REG_NOTIFY_CHANGE_LAST_SET); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1691 ADD_INT(REG_NOTIFY_CHANGE_SECURITY); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1692 ADD_INT(REG_LEGAL_CHANGE_FILTER); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1693 ADD_INT(REG_NONE); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1694 ADD_INT(REG_SZ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1695 ADD_INT(REG_EXPAND_SZ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1696 ADD_INT(REG_BINARY); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1697 ADD_INT(REG_DWORD); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1698 ADD_INT(REG_DWORD_LITTLE_ENDIAN); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1699 ADD_INT(REG_DWORD_BIG_ENDIAN); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1700 ADD_INT(REG_LINK); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1701 ADD_INT(REG_MULTI_SZ); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1702 ADD_INT(REG_RESOURCE_LIST); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1703 ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1704 ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST); |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1705 } |
|
4a61cc81f367
Mark Hammond: new winreg module; updated dllbase file.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1706 |
