|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
~Name not defined" errorHi,
I have just installed PythonCE from SourceForge on a Windows Mobile 5.0 ARM PDA (HTC P3600). When I enter in the interpreter window import _winreg help(_winreg) I get a print out of the appropriate help. When I run this script by double clicking its file from _winreg import * print r"*** Reading from SOFTWARE\Microsoft\Windows\CurrentVersion\Run ***" aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") for i in range(1024): try: n,v,t = EnumValue(aKey,i) print i, n, v, t except EnvironmentError: print "You have",i," tasks starting at logon..." break CloseKey(aKey) print r"*** Writing to SOFTWARE\Microsoft\Windows\CurrentVersion\Run ***" aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE) try: SetValueEx(aKey,"MyNewKey",0, REG_SZ, r"c:\winnt\explorer.exe") except EnvironmentError: print "Encountered problems writing into the Registry..." CloseKey(aKey) CloseKey(aReg) it prints the first line correctly but then prints Name Error: name 'ConnectRegistry' is not defined Can anyone suggest what the problem is please? Regards David Williams |
|
|
|
|
|
Re: ~Name not defined" error
|
|
|
Re: ~Name not defined" errorHi,
> aKey = OpenKey(HKEY_LOCAL_MACHINE, > r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") > > I have replaced the lines as suggested and now get the error: > <Type 'exceptions.WindowsError'>:[Error 2] The system cannot find the file > specified > > Any ideas? You have to double the backslash because it is interpreted as an esc code :) aKey = OpenKey(HKEY_LOCAL_MACHINE, r"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") Regards. _______________________________________________ PythonCE mailing list PythonCE@... http://mail.python.org/mailman/listinfo/pythonce |
|
|
Re: ~Name not defined" error
|
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |