skuallpa
23rd July 2009 12:51 UTC
global variable
Hello,
I am working on an updater. I need to know directly the current application version. So I want to initialize a variable that would contain the current version.
;Current version variable
ReadRegStr $CURRENT_VERSION HKLM Software\MySoftware "Version"
But where must I place this code? Actually, because I use ReadRegStr I have to put this code inside a function or a section.
I have tried to initialize my variable in the function .onInit, straight after
!insertmacro MUI_LANGDLL_DISPLAY but I have the warning "unknown variable" during compilation.
Var CURRENT_VERSION
!define MUI_WELCOMEPAGE_TITLE " Updater: ${CURRENT_VERSION} to ${LAST_VERSION}"
!insertmacro MUI_PAGE_WELCOME
Function .onInit
;display multilanguage list
!insertmacro MUI_LANGDLL_DISPLAY
ReadRegStr $CURRENT_VERSION HKLM Software\MySoftware "Version"
...
FunctionEnd
...
Thanks in advance for your help
sgiusto
23rd July 2009 14:05 UTC
Hello,
I use the same type of approach to read the folder where my app is installed.
The only differences are that I use something like:
ReadRegStr $R1 HKLM "key" "value"
and then
strcpy $VAR $R1
Note the usage of the $R1 var and that the reg name is between quotes
Regards
Stefano
skuallpa
23rd July 2009 14:31 UTC
Thanks for your answer sgiusto,
So I have adapted my code, this is what I have done
Var CURRENT_VERSION
!define LAST_VERSION "1.2"
...
!define MUI_WELCOMEPAGE_TITLE "Updater: ${CURRENT_VERSION} to ${LAST_VERSION}"
Function .onInit
;display multilanguage list
!insertmacro MUI_LANGDLL_DISPLAY
ReadRegStr $R1 HKLM "Software\MySoftware" "Version"
strcpy $CURRENT_VERSION $R1
...
FunctionEnd
...
but the variable is still unknown. In my welcome page, the title appear: Updater : ${CURRENT_VERSION} to 1.2
MSG
23rd July 2009 14:39 UTC
Copying the data from a register to a variable really does not make any difference.
skuallpa, your problem is that you're calling the CURRENT_VERSION variable not as a $Variable, but as a ${Define}. Remove the curly brackets:
Var CURRENT_VERSION
!define MUI_WELCOMEPAGE_TITLE " Updater: $CURRENT_VERSION to ${LAST_VERSION}"
(That is assuming that LAST_VERSION is indeed a define. Otherwise remove those brackets as well.)
skuallpa
23rd July 2009 14:50 UTC
Thanks a lot MSG, removing the curly brackets (to CURRENT_VERSION, not to LAST_VERSION because it is a constant) has corrected the problem