File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -176,12 +176,18 @@ def _RegistryGetValueUsingWinReg(key, value):
176
176
contents of the registry key's value, or None on failure. Throws
177
177
ImportError if _winreg is unavailable.
178
178
"""
179
- import _winreg
179
+ try :
180
+ # Python 2
181
+ from _winreg import OpenKey , QueryValueEx
182
+ except ImportError :
183
+ # Python 3
184
+ from winreg import OpenKey , QueryValueEx
185
+
180
186
try :
181
187
root , subkey = key .split ('\\ ' , 1 )
182
188
assert root == 'HKLM' # Only need HKLM for now.
183
- with _winreg . OpenKey (_winreg .HKEY_LOCAL_MACHINE , subkey ) as hkey :
184
- return _winreg . QueryValueEx (hkey , value )[0 ]
189
+ with OpenKey (_winreg .HKEY_LOCAL_MACHINE , subkey ) as hkey :
190
+ return QueryValueEx (hkey , value )[0 ]
185
191
except WindowsError :
186
192
return None
187
193
You can’t perform that action at this time.
0 commit comments