Skip to content
⌘ NSIS Forum Archive

2 Reg Keys, 1 Install Dir

9 posts

weidhas#

2 Reg Keys, 1 Install Dir

hi!

i want to search for reg key A und reg key B. when the one of these keys is found it should be the install dir.

i tried it with

InstallDirRegKey ...
InstallDirRegKey ...

but it don't work

...
Guest#
Do something like this:
function .onInit
ReadRegStr $0 [RegAddress_A]
StrCmp $0 "" 0 Found
ReadRegStr $0 [RegAddress_B]
StrCmp $0 "" NotFound
Found:
StrCpy $INSTDIR $0
...
NotFound:
...
functionend
-Hendri.
veekee#
I'ld have written ...

function .onInit
ReadRegStr $0 [RegAddress_A]
ReadRegStr $1 [RegAddress_B]
; if $0 and $1 are null -> goto notfound else continue
StrCmp $0 $1 NotFound 0
; (we dunno which one is the right one)
; so if $0 is empty, copy $1 (which is not) into $0
StrCmp $0 "" 0 Continue
StrCpy $0 $1
; now $0 has got the right path
...

NotFound:
...

functionend
Guest#
veekee, my code works fine.
weidhas, an example? The code supplied already was an example. But ok.
outfile 2regs.exe
name 2regs

function .onInit
; Make sure we have a regentry
WriteRegStr HKLM "Software\2regs" "dir" "c:\My docs"

; Now check the regentries as if
; we don't know the info above
ReadRegStr $0 HKLM "Software\skjgllfsg" "dir"
StrCmp $0 "" 0 Found
ReadRegStr $0 HKLM "Software\2regs" "dir"
StrCmp $0 "" NotFound
Found:
StrCpy $INSTDIR $0 ; So $INSTDIR contains install dir
MessageBox MB_OK $INSTDIR
Goto Continue
NotFound:
MessageBox MB_OK "No regsettings found!"
Continue:
functionend

section
DeleteRegKey HKLM "Software\2regs"
sectionend
-Hendri.
veekee#
Apologizes

Sure, your code works 👍 ! I didn't understood the first time i read it ! I beg your pardon, dear Smile2Me.... 🙁

Bad veekee, bad !