Blame view

regquery.py 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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