Shoutbox

python reg read - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: python reg read (/showthread.php?tid=87474)

python reg read by Jarrod on 11-26-2008 at 11:20 AM

i'm trying to detect the default proxy settings
i was planning o reading them from
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\
REG_SZ ProxyServer
but i can't work out how to use _winreg, and i can't find many examples,
so does anyone know of some code?

i'm also thinking of using twisted.conch instead of tunnelier like i thought if anyone is interested in helping it would be appreciated and possibally rewarded


RE: python reg read by segosa on 12-16-2008 at 01:51 AM

you can't find anything on it?

http://www.python.org/doc/2.5.2/lib/module--winreg.html

looks pretty detailed to me..


RE: python reg read by Jarrod on 12-16-2008 at 02:08 AM

yeah i saw that it doesn't quite help


RE: python reg read by segosa on 12-16-2008 at 02:54 AM

what do you mean it doesn't help? it outlines all the methods.

code:
import _winreg

registry = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER)
key = _winreg.OpenKey(registry, r"Software\Paint.NET")
print _winreg.QueryValueEx(key, "ColorsForm.SnappedTo")


as specified in the documentation, you get a tuple back:

(u'appWorkspace', 1)

the first item being the value, the second the type (1 = REG_SZ).

if you need to do something more complicated like enumerate a key, then use the appropriate method on the page. I don't know how to help you when all the help you need is there.
RE: python reg read by TheSteve on 12-16-2008 at 02:59 AM

Forgive my lack of python experience, but I think it would look something like this:

code:
iesettings = _winreg.OpenKey(
    _winreg.HKEY_CURRENT_USER,
    "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
    )
    value, type = _winreg.QueryValueEx(iesettings,"ProxyServer")

    # do something with the value and data.

    _winreg.CloseKey(iesettings)