regutil.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:purelove 作者: hucmosin 项目源码 文件源码
def RegisterFileExtensions(defPyIcon, defPycIcon, runCommand):
    """Register the core Python file extensions.

       defPyIcon -- The default icon to use for .py files, in 'fname,offset' format.
       defPycIcon -- The default icon to use for .pyc files, in 'fname,offset' format.
       runCommand -- The command line to use for running .py files
    """
    # Register the file extensions.
    pythonFileId = RegistryIDPyFile
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , ".py", win32con.REG_SZ, pythonFileId)
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , pythonFileId , win32con.REG_SZ, "Python File")
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , "%s\\CLSID" % pythonFileId , win32con.REG_SZ, CLSIDPyFile)
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , "%s\\DefaultIcon" % pythonFileId, win32con.REG_SZ, defPyIcon)
    base = "%s\\Shell" % RegistryIDPyFile
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , base + "\\Open", win32con.REG_SZ, "Run")
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , base + "\\Open\\Command", win32con.REG_SZ, runCommand)

    # Register the .PYC.
    pythonFileId = RegistryIDPycFile
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , ".pyc", win32con.REG_SZ, pythonFileId)
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , pythonFileId , win32con.REG_SZ, "Compiled Python File")
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , "%s\\DefaultIcon" % pythonFileId, win32con.REG_SZ, defPycIcon)
    base = "%s\\Shell" % pythonFileId
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , base + "\\Open", win32con.REG_SZ, "Run")
    win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT , base + "\\Open\\Command", win32con.REG_SZ, runCommand)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号