开发者

_winreg.CreateKey problem in Python

开发者 https://www.devze.com 2022-12-22 11:45 出处:网络
I开发者_开发百科\'m trying to create a key like this _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, \'Software\\\\Microsoft\\\\Shared Tools\\\\MSCONFIG\\\\startupreg\\\\test\\\\\')

I开发者_开发百科'm trying to create a key like this

_winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Shared Tools\\MSCONFIG\\startupreg\\test\\')

and the key is beeing created here

HKLM\Software\Wow6432Node\Microsoft\Shared Tools\MSCONFIG\startupreg\test\

why?

Yes, Windows 7 64x here


You can read the article Glenn referred to, but it will not be much help.

What you probably need is proper access rights combined with access to the 64-bit registry view:

with _winreg.CreateKeyEx(_winreg.HKEY_LOCAL_MACHINE, 
                             r"Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\", 
                             0, 
                             _winreg.KEY_WOW64_64KEY | _winreg.KEY_ALL_ACCESS) as key:

    _winreg.SetValueEx(key, "testValueName", 0, _winreg.REG_SZ, "value")

Please note the combination of those _winreg.KEY_WOW64_64KEY | _winreg.KEY_ALL_ACCESS.


http://msdn.microsoft.com/en-us/library/aa384253%28VS.85%29.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号