Archive: Read DWORD from reg if exists


Read DWORD from reg if exists
I use the following code to read a value(DWORD) from a key:


;Check for Microsoft Internet Information Services
StrCpy $2 0
StrCpy $3 0
findkey1:
EnumRegKey $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Oc Manager" $2
StrCmp $1 "Subcomponents" findvalue1
IntOp $2 $2 + 1
StrCmp $1 "" 0 findkey1
goto nokey1
findvalue1:
MessageBox MB_OK "Finding Value $1 + $2 + $3"
ReadRegDWORD $3 HKLM Software\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents iis_common
MessageBox MB_OK "Value= $1 + $2 + $3"
StrCmp $3 "" novalue1
StrCmp $3 "" 0 done1
nokey1:
MessageBox MB_OK "NOKEY: $1"
goto finish1
novalue1:
MessageBox MB_OK "NOVALUE: $3"
goto finish1
done1:
MessageBox MB_OK "Internet Information Services is installed"
goto finish1
finish1:


But i always get the NOVALUE Messagebox. What i`m i doing wrong?

Rather than comparing $3 to "", call ClearErrors before ReadRegDWORD followed by IfErrors novalue1.
Make sure you put quotes around the registry path. I bet that script does not even build as you have a space in it.

Stu