[python-win32] Re: _winreg.LoadKey

Roger Upole rwupole at msn.com
Tue Nov 28 04:25:04 CET 2006


Avery.Andrews wrote:
> Does anyone know how to use _winreg.Loadkey, or whether it is even
> implemented properly, in 2.4.2 and 2.5 (the fact that it is named
> wrong in the Docs and not covered in the test suites doesn't inspire
> confidence).
> 
> I find that I can use it to load a key into the top level
> (HKEY_LOCAL_MACHINE), but that various things don't appear
> to be released properly when Python exits, in that neither the
> key itself can be changed with regedt32, nor the file it
> was read in from deleted (due to being in use by another process),
> until the system is rebooted.

You'll need to call RegUnloadKey yourself to release it.
This doesn't seem to be wrapped in _winreg, but you
can use win32api.RegUnloadKey.

> This happens under both Win2000 and Win XP Pro.
> 
> And I can't find any way to load a subkey, e.g. code like this
> fails:
> 
> key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE')
> 
> _winreg.LoadKey(
>   key, 'My key',
>   'mykey'
>    )
> 
> as does:
> 
> key = _winreg.LoadKey(
>   _winreg.HKEY_LOCAL_MACHINE, 'Software\\My key',
>   'mykey'
>    )
> 
> both producing Access Denied errors.

According to the docs, you can only load a key directly under
HKEY_USERS or HKLM.

          Roger




More information about the Python-win32 mailing list