How can I associate an extension of a file to an program in Windows CE? It's so boring to run my Python programs using cmd. If I associate Python with my *.py files I'm going to run my program faster. Thanks!
A:
Hello,
I was searching in the Python files under my Windows CE and i found a simple code to do this, and i tweaked it to be better:
#
# 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)
This is the code, if you want you can use it to associate to other programs and other extensions.
Nathan Campos
2009-07-05 12:41:31
how did you tweak it to make it "better"? it's just setting a registry key...
Cogsy
2009-07-05 13:07:38
If you copy code verbatim from another source it is customary to give credit. This was copied from: http://mail.python.org/pipermail/pythonce/2006-January/001286.html
Andre Miller
2009-07-11 21:51:47