Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Verifying if registry key exists in 3.0b (http://forums.winamp.com/showthread.php?t=382543)

zewari 2nd October 2015 20:07

Verifying if registry key exists in 3.0b
 
Hey folks,

I was hoping to port my old nsis installer to 3.0b, which uses this registry plug-in, but it wasn't able to recognize the plug-in. My only use of it was to leverage its call for validating the existence of a registry key. What other method can I use to accomplish this task?

Anders 2nd October 2015 22:47

Posting the warnings/errors you get from the compiler is always helpful! I assume you are getting a "Plugin not found, cannot call" message and this should be your clue that you need to put the .dll in the correct subdirectory inside NSIS\Plugins\. It looks like that plugin only has a ANSI version so you should put it under x86-ansi and you will not be able to generate Unicode installers that use that plugin.

You can also use one of the other registry plugins or perform the check manually:
Quote:

Function RegKeyIsNonEmpty ; <HKCU|HKLM> <Key>
Exch $2
Exch 1
Exch $1
Push $0
ClearErrors
StrCmp HKLM $1 0 +3
EnumRegValue $0 HKLM $2 0
Goto +2
EnumRegValue $0 HKCU $2 0
IfErrors +2
StrCpy $0 1 ; Make sure the default value ("") is treated as success
StrCmp $0 "" 0 ret
StrCmp HKLM $1 0 +3
EnumRegKey $0 HKLM $2 0
Goto +2
EnumRegKey $0 HKCU $2 0
ret:
StrCpy $2 $0
Pop $0
Pop $1
Exch $2
FunctionEnd

Function RegKeyExists ; <HKCU|HKLM> <ParentKey> <SubKey>
Exch $3
Exch 1
Exch $2
Exch 2
Exch $1
Push $0
Push $4
StrCpy $4 0
loop:
StrCmp HKLM $1 0 +3
EnumRegKey $0 HKLM $2 $4
Goto +2
EnumRegKey $0 HKCU $2 $4
IntOp $4 $4 + 1
StrCmp $0 $3 +2 ; Found it?
StrCmp $0 "" 0 loop
StrCpy $2 $0 ; Set return value
Pop $4
Pop $0
Pop $1
Pop $3
Exch $2
FunctionEnd

Section
Push HKCU
Push "Software\NSIS\MRU"
Call RegKeyIsNonEmpty
Pop $0
StrCmp $0 "" 0 +3
DetailPrint "Key is empty or does not exist"
Goto +2
DetailPrint "Key exists and is not empty"

Push HKCU
Push "Software\NSIS"
Push "Symbols"
Call RegKeyExists
Pop $0
StrCmp $0 "" 0 +3
DetailPrint "Key does not exist"
Goto +2
DetailPrint "Key exists"
SectionEnd

zewari 23rd October 2015 18:05

Thanks Anders, placing the dll in the ANSI folder made the plugin work for me.


All times are GMT. The time now is 17:17.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.