|
Hi,
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 |
|
ConnectRegistry seems not to be implemented in PythonCE
However you can still replace: aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") by: aKey = OpenKey(HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") _______________________________________________ PythonCE mailing list [hidden email] http://mail.python.org/mailman/listinfo/pythonce |
|
<quote author="alexandre.delattre"> ConnectRegistry seems not to be implemented in PythonCE However you can still replace: aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") by: 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? |
|
Hi,
> 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 [hidden email] http://mail.python.org/mailman/listinfo/pythonce |
|
<quote author="David Goncalves-2"> Hi, > 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") I have now tried doubling the back slashes as shown above but get exactly the same error message as before. |
|
In reply to this post by alexandre.delattre
David Williams wrote:
> I have replaced the lines as suggested and now get the error: > <Type 'exceptions.WindowsError'>:[Error 2] The system cannot find the > file specified > > I would be grateful for any further help. > Thank you > David williams > > 2008/7/11 <[hidden email]>: > > ConnectRegistry seems not to be implemented in PythonCE > > However you can still replace: > > > aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) > > aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") > > by: > > aKey = OpenKey(HKEY_LOCAL_MACHINE, > r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") > > > _______________________________________________ > PythonCE mailing list > [hidden email] <mailto:[hidden email]> > http://mail.python.org/mailman/listinfo/pythonce > > Hmm, you must make sure the key is existing in your device registry. Try to double check this and that the key isn't mispelled (btw, I use PHM Regeditor on my pda for this kind of stuff <http://www.phm.lu/Products/PocketPC/RegEdit/>) The use of raw string r"..." notation prevents you from having to escape \ characters, maybe give a try to: aKey = OpenKey(HKEY_LOCAL_MACHINE, r"Software\Microsoft\Windows\CurrentVersion\Run") Hope it helps, Alexandre _______________________________________________ PythonCE mailing list [hidden email] http://mail.python.org/mailman/listinfo/pythonce |
| Powered by Nabble | Edit this page |
