[WinReg]>Issue when reading a registry key - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: [WinReg]>Issue when reading a registry key (/thread-2604.html) |
[WinReg]>Issue when reading a registry key - CSA75 - Mar-28-2017 Hello All, I'm trying without success to read the key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet\IEXPLORE.EXE\DefaultIcon here is the code I'm using : from winreg import * from time import sleep n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_64KEY) t = (EnumValue(n,0)) print(t)It fails with error: What am I doing wrong ?Thanks for your help RE: [WinReg]>Issue when reading a registry key - wavic - Mar-28-2017 Try this: try: n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_64KEY) except FileNotFoundError: n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_32KEY)SO https://msdn.microsoft.com/en-us/library/aa384129(v=VS.85).aspx RE: [WinReg]>Issue when reading a registry key - CSA75 - Mar-28-2017 (Mar-28-2017, 06:53 AM)wavic Wrote: Try this: Hi Wavic ! I tried but got same error... however, I can see by using regedit that the key is visible from 32-bit registry view and 64-bit registry view as well... RE: [WinReg]>Issue when reading a registry key - snippsat - Mar-28-2017 Look better in Regedit. Under "StartMenuInternet" i have browsers not "DefaultIcon". Test: from winreg import * key = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\Google Chrome\Capabilities') # Two way to read name = QueryValueEx(key, "ApplicationName") t = (EnumValue(key, 2))Use: >>> name ('Google Chrome', 1) >>> t ('ApplicationName', 'Google Chrome', 1) >>> name[0] 'Google Chrome' >>> t[1] 'Google Chrome' RE: [WinReg]>Issue when reading a registry key - CSA75 - Mar-28-2017 (Mar-28-2017, 11:44 AM)snippsat Wrote: Look better in Regedit. Yes ! you're right ! Thank you for pointing out my mistake and saved my day :-) (Mar-28-2017, 08:02 AM)CSA75 Wrote:Actually you were right ! I was trying with an incorrect registry key path..(Mar-28-2017, 06:53 AM)wavic Wrote: Try this: |