NSIS: reading DWORD from the registry?

1

I'm trying to update an existing installer to read a registry value (if it exists) and change the install settings to match existing installation settings when doing upgrade installations.

But I'm getting hung up on not being able to sucessfully read the registry value.

I write the key like this in the installer:

WriteRegDWORD HKLM "Software\${PRODUCT}" "IniPath" 0x00000026

This part works just fine, the key is created or modified, and is of type DWORD, all is well.

But then if I try to read that value back, I seem to be getting an empty value every time.

ReadRegDWORD $IniPath HKCU "Software\${PRODUCT}" "IniPath"
MessageBox MB_OK "$$IniPath=$IniPath" 

Results in printing $IniPath=

I also tried doing ClearErrors before reading and IfErrors after, and it does appear to be getting into IfErrors...but I don't understand why it would be having errors and not seeing the key. I am running 32 bit windows, so I doubt this is 64bit "wrong section of the registry" error.

The line to write the DWORD is working just fine. If I delete the registry key, and examine the registry using regedit immediately after, the key is there. But regardless of whether the key existed.

So what could be going wrong to cause it to fail to read the value, or how to debug this?

nsis
asked on Stack Overflow Jul 28, 2012 by Jessica Brown

1 Answer

1

You are writing to HKLM and reading from HKCU...

To debug registry issues you can use Process Monitor.

answered on Stack Overflow Jul 28, 2012 by Anders

User contributions licensed under CC BY-SA 3.0