from _winreg import *
import re
def subRegKey(key, patchlist):
count = QueryInfoKey(key)[0]
for index in range(count):
name = EnumKey(key, index)
result = patch.match(name)
if result:
patchlist.append(result.group(0))
if __name__ == '__main__':
patchlist = []
updates = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\'
patch = re.compile(r'Mozilla Firefox(.*)')
key = OpenKey(HKEY_LOCAL_MACHINE, updates)
subRegKey(key, patchlist)
print 'Count: ' + str(len(patchlist))
for p in patchlist:
print p
update = updates + p
print update
newkey = OpenKey(HKEY_LOCAL_MACHINE, update)
try:
i = 0
while 1:
name, value, type = EnumValue(newkey, i)
if name == "DisplayVersion":
print value
break
i+=1
except WindowsError:
pass
CloseKey(key)