extending PATH on Windows?

eryk sun eryksun at gmail.com
Fri Feb 19 13:07:24 EST 2016


On Thu, Feb 18, 2016 at 10:55 AM, Ulli Horlacher
<framstag at rus.uni-stuttgart.de> wrote:
> Ulli Horlacher <framstag at rus.uni-stuttgart.de> wrote:
>
>> > but simpler still and more reliable to just call QueryValueEx.
>>
>> I find it more complicated.
>
> I have now (after long studying docs and examples)::
>
> def get_winreg(key,subkey):
>   try:
>     rkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,key,0,winreg.KEY_READ)
>     rvalue,rtype = winreg.QueryValueEx(rkey,subkey)
>     winreg.CloseKey(rkey)
>   except WindowsError:
>     rvalue,rtype = None,None
>   return rvalue

The 2nd parameter should be named "value_name", not "subkey".

A registry key is similar to an NTFS file-system node, and values are
similar to NTFS $DATA streams [1], but with different types of data
[2] other than just REG_BINARY, to make it easier to store structured
configuration data.

[1]: https://msdn.microsoft.com/en-us/library/aa364404
[2]: https://msdn.microsoft.com/en-us/library/ms724884



More information about the Python-list mailing list