Archive: Read a reg key --- write a reg key


Read a reg key --- write a reg key
Hi there,

this was maybe asked before, but if so, I didn´t find it !

I want to read out a registry key. If it exists I want the installer to do nothing.
If it doesn´t exist I want the program to write 3 new keys.

I found all the commands in the readme, but don´t know how to put them in a right order. so please help me with that and post a complete sequence, cause I´m a totally newb in coding !



ReadRegStr $R0 HKLM "Software\myApp" shit ;Reads the Value of Shit into the Var $R0

StrCmp $R0 "VALUE" done write ;If $R0 is like "VALUE" it goes to done, if it has another value or isn't there it goes to write

write:
WriteRegStr HKLM "Software\myApp" "shit" "VALUE"
WriteRegStr HKLM "Software\myApp" "shit" "VALUE1"
WriteRegStr HKLM "Software\myApp" "shit" "VALUE2"
done:



this code was written Online, but it should work
greetz Dave

direkt mal testen ...

thanks ;)


edit:


Quote:


my function now looks like this, just for testing!
But when i´ve compiled the program it shows an error:

1 warning:
install function "key" not referenced - zeroing code (211-217) out

function "key"
ReadRegStr $R0 HKLM "Software\HKS Informatik GmbH\Kosy-KK" InstallVersion
StrCmp $R0 "4.0.1.6" done write
write:
WriteRegStr HKLM "Software\HKS Informatik GmbH\bla" "key1" "10"
WriteRegStr HKLM "Software\HKS Informatik GmbH\bla" "key2" "11"
WriteRegStr HKLM "Software\HKS Informatik GmbH\bla" "key3" "12"
done:
functionend

You have to call your function key in another function or section, else it isn't referenced and so the Compiler will leave it out

If you have a main section which is installed anyway, put there the Line "call key"

the other option is to don't put the code in a Function but in the Section where you need it.

If you write a function you ever have to call it

Hope this helps to understand

greetz Dave


wohoo ... now it´s doing fine and works like it´s meant to be ! thanks a lot

p.s
danke