Skip to content
⌘ NSIS Forum Archive

IfKeyExists??

36 posts

AnalogKid#
Yes, sorry, I figured out what was wrong right about the same time I woke up and went home ... EnumRegValue is what I really wanted rather than EnumRegKey ;-)

Thanks for the cool fn/macro and the ideas with the self-generating labels. I've never tried that before -- didn't know it would work ;-)

I love these forums ... I get so much inspiration sometimes just by glancing through 'em!

AnalogKid
=^{D}
n0On3#
Originally posted by Vytautas
As for the other problem. 'DisplayName' is NOT a key, keys appear as folders in regedit, so thats why the function does not work.
I still don't understand.

ClearErrors
ReadRegStr $5 HKCR ".art\ShellEx.test" ""
Iferrors "" noter
MessageBox MB_OK "error"
noter:
This checks for the "(Default)" name which something every key (folder 😉) has.

The only fault I can imagine is what kichik says: that the error flag could be triggered when it can't be opened because of security or can't be queried.
Vytautas#
Although every key has that entry it is not set, e.g. is Null, and therefore NSIS sets the error flag as if the entry did not exist.

Vytautas
cherdeg#
Why doesn't this code work?

Hi,

I try to use your macro to check for a certain registry key, this is my code:

[...]
;Check if the standard Cygwin Registry keys exist (x32)
!insertmacro IfKeyExists HKLM "SOFTWARE\Cygnus Solutions\Cygwin\mounts v2" "cygdrive flags"
Pop $R0
IntCmp $R0 0 DoInstall ByReg ByReg
;Check if the standard Cygwin Registry keys exist (x64)
!insertmacro IfKeyExists HKLM "SOFTWARE\Wow6432Node\Cygnus Solutions\Cygwin\mounts v2" "cygdrive flags"
Pop $R0
IntCmp $R0 0 DoInstall ByReg ByReg

;This is the label to jump to if a registy key is found
ByReg:
MessageBox MB_ICONSTOP "RegistryKeys for Cygwin exist on this machine. Please first remove any installation of cygwin and then restart this installer..."
Quit

;This is the label to jump to if Cygwin is not installed yet.
DoInstall:
[...]

Why wouldn't it jump to ByReg if the key is found?

Please help - I'm lost...

Regards,

Chris
PoRtAbLe_StEaLtH#
Originally Posted by cherdeg View Post
Hi,

I try to use your macro to check for a certain registry key, this is my code:

[...]
;Check if the standard Cygwin Registry keys exist (x32)
!insertmacro IfKeyExists HKLM "SOFTWARE\Cygnus Solutions\Cygwin\mounts v2" "cygdrive flags"
Pop $R0
IntCmp $R0 0 DoInstall ByReg ByReg
;Check if the standard Cygwin Registry keys exist (x64)
!insertmacro IfKeyExists HKLM "SOFTWARE\Wow6432Node\Cygnus Solutions\Cygwin\mounts v2" "cygdrive flags"
Pop $R0
IntCmp $R0 0 DoInstall ByReg ByReg

;This is the label to jump to if a registy key is found
ByReg:
MessageBox MB_ICONSTOP "RegistryKeys for Cygwin exist on this machine. Please first remove any installation of cygwin and then restart this installer..."
Quit

;This is the label to jump to if Cygwin is not installed yet.
DoInstall:
[...]

Why wouldn't it jump to ByReg if the key is found?

Please help - I'm lost...

Regards,

Chris

you have 2 'ByReg'.

it should be:
IntCmp $R0 0 DoInstall ByReg
Also.. if you're checking x64 reg key.. use SetRegView 64.