[pywin32-checkins] /hgrepo/p/py/pywin32/pywin32: In GetRootKey, return HKCU when in...
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2011-07-16 07:07:54
|
changeset cf92dfed72c8 in /hgrepo/p/py/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgrepo/p/py/pywin32/pywin32?cmd=changeset;node=cf92dfed72c8 summary: In GetRootKey, return HKCU when installed per-user diffstat: win32/Lib/regutil.py | 31 ++++++++++++++++--------------- 1 files changed, 16 insertions(+), 15 deletions(-) diffs (51 lines): diff -r 39838376f973 -r cf92dfed72c8 win32/Lib/regutil.py --- a/win32/Lib/regutil.py Tue Jul 12 01:50:52 2011 -0400 +++ b/win32/Lib/regutil.py Thu Jul 14 21:22:17 2011 -0400 @@ -12,14 +12,25 @@ RegistryIDPyFile = "Python.File" # The registry "file type" of a .py file RegistryIDPycFile = "Python.CompiledFile" # The registry "file type" of a .pyc file +def BuildDefaultPythonKey(): + """Builds a string containing the path to the current registry key. + + The Python registry key contains the Python version. This function + uses the version of the DLL used by the current process to get the + registry key currently in use. + """ + return "Software\\Python\\PythonCore\\" + sys.winver + def GetRootKey(): """Retrieves the Registry root in use by Python. """ -# Win32s no longer supported/released. -# if win32ui.IsWin32s(): -# return win32con.HKEY_CLASSES_ROOT -# else: - return win32con.HKEY_LOCAL_MACHINE + keyname = BuildDefaultPythonKey() + try: + k = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyname) + k.close() + return win32con.HKEY_CURRENT_USER + except win32api.error: + return win32con.HKEY_LOCAL_MACHINE def GetRegistryDefaultValue(subkey, rootkey = None): """A helper to return the default value for a key in the registry. @@ -39,16 +50,6 @@ raise TypeError("Value must be string or integer - was passed " + repr(value)) win32api.RegSetValue(rootkey, subKey, typeId ,value) - -def BuildDefaultPythonKey(): - """Builds a string containing the path to the current registry key. - - The Python registry key contains the Python version. This function - uses the version of the DLL used by the current process to get the - registry key currently in use. - """ - - return "Software\\Python\\PythonCore\\" + sys.winver def GetAppPathsKey(): return "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths" |