【发布时间】:2009-07-05 12:29:42
【问题描述】:
如何将文件的扩展名与 Windows CE 中的程序相关联?使用 cmd 运行我的 Python 程序真是太无聊了。如果我将 Python 与我的 **.py* 文件相关联,我将更快地运行我的程序。谢谢!
【问题讨论】:
标签: associations windows-ce file-association
如何将文件的扩展名与 Windows CE 中的程序相关联?使用 cmd 运行我的 Python 程序真是太无聊了。如果我将 Python 与我的 **.py* 文件相关联,我将更快地运行我的程序。谢谢!
【问题讨论】:
标签: associations windows-ce file-association
我在我的 Windows CE 下的 Python 文件中搜索,我找到了一个简单的代码来执行此操作,我对其进行了调整以使其更好:
#
# Setup the registry to allow us to double click on python scripts
#
from _winreg import *
print "Setting up registry to allow\ndouble clicking of Python files to work"
#
# Create the registry entries for ".py" and ".pyc" extensions
#
for Name in (".py", ".pyc"):
Key = CreateKey(HKEY_CLASSES_ROOT, Name)
SetValue(Key, None, REG_SZ, "Python.File")
CloseKey(Key)
#
# Create HKEY_CLASSES_ROOT\Python.File\Shell\Open\Command = "\Program Files\Python\Lib\Python.exe" "%1"
#
Key = CreateKey(HKEY_CLASSES_ROOT, "Python.File")
for Name in ("Shell","Open","Command"):
New_Key= CreateKey(Key, Name)
CloseKey(Key)
Key = New_Key
SetValue(Key, None, REG_SZ, "\"\\Program Files\\Python\\Lib\\Python.exe\" \"%1\"")
CloseKey(Key)
import time
time.sleep(5)
这是代码,如果您愿意,可以使用它来关联其他程序和其他扩展。
【讨论】: