regquery.py
865 Bytes
from Registry import Registry
def queryValue(hive,key,valueName):
reg = Registry.Registry(hive)
key = reg.open(key)
try:
value = str(key.value(valueName).value)
except Registry.RegistryParse.RegistryStructureDoesNotExist:
value = None
return value
def getValues(hive,key):
valueList = []
reg = Registry.Registry(hive)
key = reg.open(key)
for value in key.values():
valueList.append(value.value)
return valueList
def getSubkeys(hive,key):
subkeyList = []
reg = Registry.Registry(hive)
key = reg.open(key)
for subkey in key.subkeys():
subkeyList.append(subkey.name)
return subkeyList
def keyExists(hive,key):
reg = Registry.Registry(hive)
try:
key = reg.open(key)
return True
except Registry.RegistryKeyNotFoundException:
return False