WindowsでPhotoshopのインストールパスを取得する
code: get_photoshop_path.py
import winreg
def get_photoshop_paths():
base_path = r"SOFTWARE\Adobe\Photoshop"
res = []
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, base_path) as key:
subkey_length, _, __ = winreg.QueryInfoKey(key)
for i in range(subkey_length):
subkey = winreg.EnumKey(key, i)
target_key = winreg.OpenKeyEx(key, subkey)
try:
application_path, _ = winreg.QueryValueEx(target_key, "ApplicationPath")
res.append(application_path)
except WindowsError:
pass
return res
print(get_photoshop_paths())