Archive: Need Help Reading Registry


Need Help Reading Registry
I am new to NSIS but things been going pretty smooth up until I been trying to read the registry. I tried the built in method ReadRegStr and the Registry.nsh plugin method but keep getting null. Its got to be something simple. I am able to write to the registry fine, but when I try to read I get null. Here is a sample I tried.

!include Registry.nsh
${registry::Read} "HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\7.0" "InstallPath" $0 $1

Messagebox MB_OK $0
Messagebox MB_OK $1


try this,
ReadRegStr $0 HKLM "Software\NSIS" ""
Messagebox MB_OK "$0"


That works, So what am I doing wrong.


Try to change this,
"HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\7.0" "InstallPath"

With this,
HKEY_LOCAL_MACHINE "SOFTWARE\Adobe\Acrobat Reader\7.0" "InstallPath"

or,
HKLM "SOFTWARE\Adobe\Acrobat Reader\7.0" "InstallPath"


I tried both and that doesn't work. It seems like anything more than the basic bellow won't work.

ReadRegStr $0 HKLM "Software\NSIS" ""
Messagebox MB_OK "$0"


provided that Acrobat is installed on your system and the registry record you're trying to read exists and there isn't any typo, this is the code,

ReadRegStr $0 HKLM "SOFTWARE\Adobe\Acrobat Reader\7.0" "InstallPath"
Messagebox MB_OK "$0"

I figured I was doing everything right. If you have adobe installed try this. I wonder if its just my PC or is something buggy.


Unfortunately there isn't acrobat in my system, I'm satisfied with Foxit reader :)
Anyway you might want to check this example

WriteRegStr HKCU "Software\My Application" "InstallPath" "Hey my application install path should be here"
ClearErrors
ReadRegStr $0 HKCU "Software\My Application" "InstallPath"
IfErrors +2
MessageBox MB_OK "$0" IDOK next
MessageBox MB_OK "Error no such registry record"
next:
ClearErrors
ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Adobe\Acrobat Reader\7.0" "InstallPath"
IfErrors +2
MessageBox MB_OK "$0" IDOK end
MessageBox MB_OK "Error no such registry record"
end:

The First Read works the second one doesn't. I thought it was the "." period, but I tried some simple examples that have periods that work.


There is not problem with periods, should be a typo, no other explanation.
Looking in my registry (I have Audition installed) it is,
HKLM "SOFTWARE\Adobe\Audition\2.0" "ApplicationPath"
Maybe it is also "ApplicationPath" for Acrobat and not "InstallPath"?

Talking about managing registry, a couple of weeks ago I've posted some examples to help a user, you might find them useful as well.

http://forums.winamp.com/attachment....postid=2087784


Hmmm, I copied the Key right out of the registry so I don't see how it could be a typo. Here it is from an export.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\7.0\InstallPath]
@="C:\\Program Files\\Adobe\\Acrobat 7.0\\Reader"


Now we got it, here it is

ReadRegStr $0 HKLM "SOFTWARE\Adobe\Acrobat Reader\7.0\InstallPath" ""

Ok, that worked.

Now Help me do understand the difference. When do you uses pass the third parm and when do you include it in the second parm?

Thanks for all your help.


I shaw it in the regedit export.
InstallPath isn't a value name, it is a key and the value data is added to (default) @=(default).

When we read from registry within NSIS we need to quote all the keys sequence e.g "SOFTWARE\Adobe\Acrobat Reader\7.0\InstallPath" then quote the value name which contains the value data we want to read. When there isn't value name -this is the (default)- then we add empty quotes.

The same goes when we want to write data to (default).