Blame view

regquery.py 865 Bytes
1
2
from Registry import Registry
Imanol-Mikel Barba Sabariego authored
3
def queryValue(hive,key,valueName):
4
    reg = Registry.Registry(hive)
Imanol-Mikel Barba Sabariego authored
5
    key = reg.open(key)
6
7
    try:
        value = str(key.value(valueName).value)
Imanol-Mikel Barba Sabariego authored
8
    except Registry.RegistryParse.RegistryStructureDoesNotExist:
9
10
11
12
13
14
        value = None
    return value

def getValues(hive,key):
    valueList = []
    reg = Registry.Registry(hive)
Imanol-Mikel Barba Sabariego authored
15
16
17
    key = reg.open(key)
    for value in key.values():
        valueList.append(value.value)
18
19
20
21
22
    return valueList

def getSubkeys(hive,key):
    subkeyList = []
    reg = Registry.Registry(hive)
Imanol-Mikel Barba Sabariego authored
23
    key = reg.open(key)
24
25
26
27
28
29
30
31
32
33
34
    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