View Single Post
Old 17th February 2014, 16:42   #24
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,216
Quote:
Originally Posted by LoRd_MuldeR View Post
So we can check for Win2k+, but the check for WinXP+ is going to fail always
Guess what? The XP check works fine and the docs are wrong.

I know this cannot be used for future detection but it can probably help with detecting 8.1 if that is all you need and you don't want to mess with the manifest.

Here is some code I wrote a while ago but never tested:
code:
!include LogicLib.nsh
push $0
push $9
System::Call '*(i148,i,i,i,i,&w128,i,i)p.r0'
!if "${NSIS_PTR_SIZE}" <= 4
System::Call 'kernel32::GetVersionExA(pr0)i.r9' ; OSVERSIONINFOA for Win95
System::Call '*$0(i,i.r1,i.r2)'
System::Call 'kernel32::VerifyVersionInfoW(pr0,i 3,l 20)i.r9'
${If} $9 == 0 ; GetVersionEx lied (Must use string test, if VerifyVersionInfoW does not exist the string will be "error" and that converts to 0 for number testing)
!endif
StrCpy $1 3 ; NT4.SP4 has VerifyVersionInfo
${Do}
IntOp $1 $1 + 1
System::Call '*$0(i276,ir1,i0)'
System::Call 'kernel32::VerifyVersionInfoW(pr0,i 2,l 16)i.r9'
${LoopWhile} $9 = 0
StrCpy $2 -1
${Do}
IntOp $2 $2 + 1
System::Call '*$0(i,i,ir2)'
System::Call 'kernel32::VerifyVersionInfoW(pr0,i 3,l 20)i.r9'
${LoopWhile} $9 = 0
!if ${NSIS_PTR_SIZE} <= 4
${EndIf}
!endif
System::Free $0
pop $9
pop $0
DetailPrint WinVer=$1.$2


IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote