Talk:Version plug-in

From NSIS Wiki
(Redirected from Talk:Detect Windows Version)
Jump to navigationJump to search

I get an error in the script. It doesn't seem to like the "Pop $MajorVersion" line, and if I take this out, if just fails on the next "Pop" line. The dll is in the directory, and it compiles fine without the detect code. If I hover over POP it gives "Usage: Pop $(user_var: output)". I'm using HM NIS Edit 2.0.3 to edit scripts for NSIS 2.08.

Does not run on Windows Server 2000 through Terminal Server. Gives "5." as a version.

Problem's if OS not have Service Pack or any version elements

Sometimes, if the value of a version number of the system is not defined, or does not exist, then the library puts on the stack as the value of empty string, which then causes an error in the algorithms for further processing. To avoid these errors is sufficient to check the condition that the value is from the stack is not empty, and if it is empty give it a value equal to zero. This will avoid errors in cases when the user's machine is not set such a service pack - the registry key containing the number of Service Pak missing, and the library returns to him empty string. The correct code, which takes into account such practical situation is given in the example below:


  Outfile test.exe
  ShowInstDetails show
  Section "main"
  Version::GetWindowsVersion
  Pop $0
  StrCmp $0 "" +1 +2
  StrCpy $0 0
  Pop $1
  StrCmp $1 "" +1 +2
  StrCpy $1 0
  Pop $2
  StrCmp $2 "" +1 +2
  StrCpy $2 0
  Pop $3
  StrCmp $3 "" +1 +2
  StrCpy $3 0
  Pop $4
  StrCmp $4 "" +1 +2
  StrCpy $4 0
  DetailPrint "$$0 == $0"
  DetailPrint "$$1 == $1"
  DetailPrint "$$2 == $2"
  DetailPrint "$$3 == $3"
  DetailPrint "$$4 == $4"
  SectionEnd