Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Need Help Reading Registry (http://forums.winamp.com/showthread.php?t=265470)

wogman75 9th February 2007 16:25

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

Red Wine 9th February 2007 16:30

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

wogman75 9th February 2007 16:34

That works, So what am I doing wrong.

Red Wine 9th February 2007 16:40

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"

wogman75 9th February 2007 16:46

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"

Red Wine 9th February 2007 16:50

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,

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


wogman75 9th February 2007 17:03

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.

Red Wine 9th February 2007 17:11

Unfortunately there isn't acrobat in my system, I'm satisfied with Foxit reader :)
Anyway you might want to check this example
code:
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:


wogman75 9th February 2007 17:40

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.

Red Wine 9th February 2007 17:56

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

wogman75 9th February 2007 18:08

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"

Red Wine 9th February 2007 18:13

Now we got it, here it is
code:
ReadRegStr $0 HKLM "SOFTWARE\Adobe\Acrobat Reader\7.0\InstallPath" ""

wogman75 9th February 2007 18:24

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.

Red Wine 9th February 2007 18:36

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).


All times are GMT. The time now is 04:44.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.