Support Python 2.7 and Python 3 winreg imports on Windows

This commit is contained in:
Derek Tracy
2021-02-24 20:54:39 -05:00
committed by NoDRM
parent d9353bdd93
commit 1545d76803
10 changed files with 41 additions and 10 deletions

View File

@@ -20,7 +20,10 @@ class SimplePrefs(object):
self.file2key[filename] = key
self.target = target + 'Prefs'
if sys.platform.startswith('win'):
import winreg
try:
import winreg
except ImportError:
import _winreg as winreg
regkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\")
path = winreg.QueryValueEx(regkey, 'Local AppData')[0]
prefdir = path + os.sep + self.target