Skip to content
⌘ NSIS Forum Archive

ReadRegStr and user variables

4 posts

IGx89#

ReadRegStr and user variables

I'm trying to do the following:

ReadRegStr $2 HKLM $R4 $R7

It doesn't work, but if replace R4 and R7 with their values, then it does. I've double-checked for typos, and haven't found any. What am I doing wrong?

Thanks!
Mottel#
Should Work

The following worked for me using NSIS 2.0b under Windows 98 SE.

;--------------------------
# [Global Pseudo-constants]
;--------------------------
!Define TrialName "ReadRegTest"

;------------------
# [.exe Attributes]
;------------------

Name "${TrialName}"
OutFile "${TrialName}.exe"
Caption ""
Subcaption 3 ": Trial"
ShowInstDetails show

;------
Section
;------
StrCpy $R4 ".MP3"
StrCpy $R7 "Content Type"
ReadRegStr $2 HKCR $R4 $R7
DetailPrint $2
SectionEnd ; ================================
Output in the listbox is: audio/mid
NOTE: It worked OK even without enclosing $R7 in quotes.
Are you getting a compile error or just no output?
Are you sure the ValueName you're trying to read exists in the registry?
IGx89#
I finally found out my problem: there was a newline at the end of one of the vars! I thought the messagebox I used to debug automatically made a new line because of space constraints, not because it was in one of the vars! Oh well, live and learn 🙂