1

以下のコードは、レジストリ設定について私が学んだことに基づいて、ファイルの種類の既定のアイコンと既定のアプリケーションを設定することを目的としています。regedit を使用して変更が行われていることがわかりますが、その拡張子を持つファイルの情報は変更されていません。これを行う方法に関する提案はありますか?

import os.path
import _winreg as winreg

G2path="Z:\\Scratch\\GSASII"
G2icon = 'c:\\gsas2.ico,0'
G2bat = os.path.join(G2path,'RunGSASII.bat')

gpxkey = winreg.CreateKey(winreg.HKEY_CURRENT_USER,r'Software\CLASSES\.gpx')
#gpxkey = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, '.gpx')
iconkey = winreg.CreateKey(gpxkey, 'DefaultIcon')
winreg.SetValue(iconkey, None, winreg.REG_SZ, G2icon)
openkey = winreg.CreateKey(gpxkey, 'OpenWithList')
g2key = winreg.CreateKey(openkey, 'GSAS-II')
winreg.SetValue(g2key, None, winreg.REG_SZ, G2bat)

winreg.CloseKey(iconkey)
winreg.CloseKey(g2key)
winreg.CloseKey(openkey)
#winreg.CloseKey(gpxkey)
winreg.FlushKey(gpxkey)
4

1 に答える 1