Archive: Read version out .ini file


Write and read version out registry
Hi,

I wanna make a patch for my application.
So I gotta write a registry string for the previous version
and have to read this registry string in the new version,
right?

But how i do this?
(version is 1.0)

WriteRegStr HKLM "Software/Example" "" "${PRODUCT_VERSION}"

is that right?

And in the setup for the new version

ReadRegStr HKLM "Software/Example" "" "....." ;and now? this is my first problem

When I find it out, how I insert a condition, that ask for the registry and version of the old version.

The setup shouldn´t to continue, if the previous version not installed on the system. But it shouldn´t check, if a file is installed.
This is the reason why I need this stuff with the registry bla bla.

Oh sh*t, my english is so bad :(
I hope your understand me and can help.

ps: I don´t look over the documention for the registry stuff

EDIT:
I´ve choose a wrong thread name. "Read version out .ini file" was my misstake, sry.


you're mixing up WriteRegStr with WriteINIStr and ReadRegStr with ReadINIStr. if you want to write the version into an ini-file (myfile.ini) you will need to use WriteINIStr/ReadINIStr. if you want the version stored in the windows registry, you must use WriteRegStr/ReadRegStr.

the other problem is that you don't use the correct syntax for each Read command.

try this:

WriteRegStr "HKLM" "Software/Example" "" "${PRODUCT_VERSION}"
ReadRegStr $0 "HKLM" "Software/Example" ""

or
WriteINIStr "$EXEDIR\MyFile.ini" "MySection" "Version" "${PRODUCT_VERSION}"
ReadINIStr $0 "$EXEDIR\MyFile.ini" "MySection" "Version"

in both cases the value is in the string $0

Thanks.

In the setup of the previous version I insert:


WriteRegStr "HKLM" "Software/Example" "" "${PRODUCT_VERSION}"


And in the setup of the new version I insert:

ReadRegStr $0 "HKLM" "Software/Example" ""


But with wich command I have to insert the condition?
If version xyz than ...

else
....

How I do this?

Check out this:

Comparing full versions numbers (xx.xx.xx.xx ? xx.xx.xx.xx)

You can compare the return value with IntCmp. Like:

IntCmp $var 1 IfNewer IfEqual IfOlder
IfNewer:

# put commands, or wharever you like.

Goto End

IfEqual:

# put commands, or wharever you like.

Goto End

IfOlder:

# put commands, or wharever you like.

End:

It´s so damn complicated or I´m dumb like bread.

I´ve insert this (in the setup for the new version):


WriteRegStr "HKLM" "Software/Map2" "" "${PRODUCT_VERSION}"
ReadRegStr $0 "HKLM" "Software/Map" ""
IntCmp $var 1 IfNewer IfEqual IfOlder
IfNewer:

Messagebox MB_OK "Older Version was found"

Goto End

IfEqual:

Messagebox MB_OK "Same Version was found"

Goto End

IfOlder:

Messagebox MB_OK "Newer Version was found"

End:


But if I install the new version (with this code) it´s
show "Same Version was found". But it´s have to show
"Older Version was found".

What´s wrong?

Sry, I´m a noob.

Sorry, I was expecting you to use that function I pointed out, because you can't compare dotted versions with IntCmp alone.


I´ve checked out thee link, wich u give me.
I´ve tryed the scripts but it doesn´t work.

It´s to puke >_< .

I can script simply installers with downloads, with subsection, with custompages but not this! *arg*

Now I have tryed the code from the NSIS setup.
The code with "add/reinstall components" and "remove".
It´s checked the version, too.
It´s works halfways. The only problem is, that the setup show, it´s an older version installed. Doing so it is
the same version. :mad:

Please, u have to help me. It´s damn important.


Hmmm... I read more about this function and it's not what expected. I used a function called "Version Check" function (where can I find it?).

Use this code where you want to detect the version:

ReadRegStr $0 "HKLM" "Software/Map" ""

Push $0
Push ${PRODUCT_VERSION}
Call VersionCheck
Pop $1

IntCmp $1 1 IfNewer IfEqual IfOlder
IfNewer:

# put commands, or wharever you like.

Goto End

IfEqual:

# put commands, or wharever you like.

Goto End

IfOlder:

# put commands, or wharever you like.

End:
Put this at the bottom of the script, outside functions and sections:

Function VersionCheck
Exch $0 ;second versionnumber
Exch
Exch $1 ;first versionnumber
Push $R0 ;counter for $0
Push $R1 ;counter for $1
Push $3 ;temp char
Push $4 ;temp string for $0
Push $5 ;temp string for $1
StrCpy $R0 "-1"
StrCpy $R1 "-1"
Start:
StrCpy $4 ""
DotLoop0:
IntOp $R0 $R0 + 1
StrCpy $3 $0 1 $R0
StrCmp $3 "" DotFound0
StrCmp $3 "." DotFound0
StrCpy $4 $4$3
Goto DotLoop0
DotFound0:
StrCpy $5 ""
DotLoop1:
IntOp $R1 $R1 + 1
StrCpy $3 $1 1 $R1
StrCmp $3 "" DotFound1
StrCmp $3 "." DotFound1
StrCpy $5 $5$3
Goto DotLoop1
DotFound1:
StrCmp $4 "" 0 Not4
StrCmp $5 "" Equal
Goto Ver2Less
Not4:
StrCmp $5 "" Ver2More
IntCmp $4 $5 Start Ver2Less Ver2More
Equal:
StrCpy $0 "0"
Goto Finish
Ver2Less:
StrCpy $0 "1"
Goto Finish
Ver2More:
StrCpy $0 "2"
Finish:
Pop $5
Pop $4
Pop $3
Pop $R1
Pop $R0
Pop $1
Exch $0
FunctionEnd

Thank you! Thank you! Thank you! Thank you! Thank you!

It´s work!

At first time I had make it so like u said.
It had doesn´t work.

The mistake was this:


ReadRegStr $0 "HKLM" "Software/Map" ""


It have to be:

ReadRegStr $0 "HKLM" "Software\Map" ""


A backslash.

And it´s work now!
Thanks!