Registry problem

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Registry problem

Post by Mastiff » Mon Feb 08, 2016 5:23 pm

I have this code (not made by me, of course) to get a value out of the registry:

Code: Select all

def HentRegisterAlarm(var1, var2):
    const1 = 2147483649L
    const2 = u'Software\\Automatisering\\Alarm\\'
    const3 = 1
    const4 = u''
    res = eg.plugins.System.RegistryQuery(const1, const2+var1, var2, const3, const4)
    return int(res)
The format in the registry is this:

Code: Select all

[HKEY_CURRENT_USER\Software\Automatisering\Alarm]

[HKEY_CURRENT_USER\Software\Automatisering\Alarm\1]
"1"="3"
"Modus"="1"
"2"="None"

[HKEY_CURRENT_USER\Software\Automatisering\Alarm\21]
"2"="10"
"Modus"="2"
"1"="None"
Now I need to get something out of this format:

Code: Select all

[HKEY_CURRENT_USER\Software\Automatisering\Lydogbilde\Forsterkere]
"8"="false"
"7"="false"
"6"="false"
"3"="false"
"5"="false"
And I just keep messing it up all the time! I have spent an hour messing around with constants and variables, but it keeps getting mixed up, and I never get the correct format. Can somebody please (as I usually say in these situations...) put me out of my misery? The difference is one layer. The first one is organized with subkeys with DWORD entries, while what I want to do now only has DWORD entries. I also need to write back to the registry. For the one that's working this is the code:

Code: Select all

def SettRegisterAlarm(Rom, Register, Verdi):
    const1 = 2147483649L
    const2 = u'Software\\Automatisering\\Alarm\\'
    res = eg.plugins.System.RegistryChange(const1, const2+Rom, Register, 0, None, Verdi)
    return res

Post Reply