import winreg
#需要遍历的两个注册表
sub_key = [r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', r'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall']
for i in sub_key:
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, i)
for j in range(winreg.QueryInfoKey(key)[0]):
try:
each_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, f'{i}\\{winreg.EnumKey(key, j)}')
DisplayName = winreg.QueryValueEx(each_key, 'DisplayName')[0]
print(DisplayName.encode('utf-8'))
except WindowsError:
pass
网友评论