regquery.py 870 Bytes
from Registry import Registry

def queryValue(hive,keyPath,valueName):
    reg = Registry.Registry(hive)
    key = reg.open(keyPath)
    try:
        value = str(key.value(valueName).value)
    except Registry.RegistryValueNotFoundException:
        value = None
    return value

def getValues(hive,key):
    valueList = []
    reg = Registry.Registry(hive)
    key = reg.open(keyPath)
	for value in key.values():
        valueList.append(value.value_name)
    return valueList

def getSubkeys(hive,key):
    subkeyList = []
    reg = Registry.Registry(hive)
    key = reg.open(keyPath)
    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