0

如何将文件的扩展名与 Windows CE 中的程序相关联?使用cmd运行我的 Python 程序太无聊了。如果我将 Python 与我的 **.py* 文件相关联,我将更快地运行我的程序。谢谢!

4

1 回答 1

0

我在我的 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)

这是代码,如果您愿意,可以使用它来关联其他程序和其他扩展。

于 2009-07-05T12:41:31.170 回答