[wxPython-users] Accessing the windows registry
by Philippe Ney other posts by this author
Apr 15 2003 9:47AM messages near this date
Re: [wxPython-users] A question on wxPython + PIL and a possible
bug
|
Re: [wxPython-users] Accessing the windows registry
Hi,
I need to access the windows registry on an XP system.
In this way, I just write the following prog which do
the trick using the python _winreg module and the
wxConfigBase class
---8<------------------------
import _winreg
from wxPython.wx import *
def GetParam () :
# Open HKEY_LOCAL_MACHINE.
key =_winreg.ConnectRegistry (None, _winreg.HKEY_LOCAL_MACHINE)
subKey = _winreg.OpenKey (key, 'SOFTWARE\\Jabber\\Exodus\\')
infoKey =_winreg.QueryInfoKey (subKey)
print infoKey
value = _winreg.QueryValueEx (subKey, 'Install_Dir')
print value
_winreg.CloseKey (subKey)
def GetParam2 () :
key = wxConfigBase (None)
value = key.Exists ('HKEY_LOCAL_MACHINE\\SOFTWARE\\Jabber\\Exodus')
print value
GetParam ()
GetParam2 ()
----8<---------------------------
which output is the following :
(0, 1, 126919629731703750L)
(u'C:\\Program Files\\Exodus', 1)
Traceback (most recent call last):
File "reg.py", line 33, in ?
GetParam2 ()
File "reg.py", line 27, in GetParam2
value = key.Exists ('HKEY_LOCAL_MACHINE\\SOFTWARE\\Jabber\\Exodus')
File "C:\Python22\Lib\site-packages\wxPython\utils.py", line 29, in Exists
val = apply(utilsc.wxConfigBase_Exists,(self,) + _args, _kwargs)
TypeError: Type error in argument 1 of wxConfigBase_Exists. Expected
_wxConfigBase_p.
Exception exceptions.AttributeError: "wxConfigBase instance has no
attribute 'thisown'" in <bound method wxConfigBase.__del__ of <C
wxConfigBase instance at None> > ignored
It works when I use _winreg but using the wxConfigBase class seems
not to be as simple as I thought...
I start with python and I interpret the error as the 'Exists' methode
want something like a pointer ...
I think I missuse the wxConfigBase class but I don't find more doc than
the one in wxWindows that seems not sufficient for me :(
Did someone have tips, links, explanations or anything that could help me?
Thanks,
-philippe
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@[...].org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
Thread:
Philippe Ney
Robin Dunn
Philippe Ney
|