mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
Minor adjustment to GetRegistryKey to support 64-bit windows
This commit is contained in:
parent
2ce8a65fc4
commit
e2680bb836
@ -283,26 +283,38 @@ def GetDirectoryContents(dir, filters="*", skip=[]):
|
|||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
import _winreg
|
import _winreg
|
||||||
|
|
||||||
|
def TryRegistryKey(path):
|
||||||
|
try:
|
||||||
|
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, path, 0, _winreg.KEY_READ)
|
||||||
|
return key
|
||||||
|
except: pass
|
||||||
|
try:
|
||||||
|
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, path, 0, _winreg.KEY_READ | 256)
|
||||||
|
return key
|
||||||
|
except: pass
|
||||||
|
return 0
|
||||||
|
|
||||||
def ListRegistryKeys(path):
|
def ListRegistryKeys(path):
|
||||||
result=[]
|
result=[]
|
||||||
index=0
|
index=0
|
||||||
try:
|
key = TryRegistryKey(path)
|
||||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, path, 0, _winreg.KEY_READ)
|
if (key != 0):
|
||||||
while (1):
|
try:
|
||||||
result.append(_winreg.EnumKey(key, index))
|
while (1):
|
||||||
index = index + 1
|
result.append(_winreg.EnumKey(key, index))
|
||||||
except: pass
|
index = index + 1
|
||||||
if (key!=0): _winreg.CloseKey(key)
|
except: pass
|
||||||
|
_winreg.CloseKey(key)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def GetRegistryKey(path, subkey):
|
def GetRegistryKey(path, subkey):
|
||||||
k1=0
|
k1=0
|
||||||
key=0
|
key = TryRegistryKey(path)
|
||||||
try:
|
if (key != 0):
|
||||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, path, 0, _winreg.KEY_READ)
|
try:
|
||||||
k1, k2 = _winreg.QueryValueEx(key, subkey)
|
k1, k2 = _winreg.QueryValueEx(key, subkey)
|
||||||
except: pass
|
except: pass
|
||||||
if (key!=0): _winreg.CloseKey(key)
|
_winreg.CloseKey(key)
|
||||||
return k1
|
return k1
|
||||||
|
|
||||||
def oscmd(cmd):
|
def oscmd(cmd):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user