简体   繁体   中英

NSIS Get Product Version

I am trying to get the ProductVersion using NSIS 2.49. Does anyone have examples on how to get the product version?

GetDllVersion  "C:\data\Some.exe" $R0 $R1 ;the two values were read during compilation

IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
MessageBox MB_OK '$R2.$R3.$R4.$R5'

I have tried the above but, it is just retrieving a the File Version.

NSIS does not have native support for this, you have to call the Windows API directly:

Function GetDllProductVersion
System::Store S
Pop $3
System::Call 'VERSION::GetFileVersionInfoSize(tr3,*i)i.r4'
System::Call '*(&i$4,t""r1,t""r2)i.r5' ; Set $1 and $2 to "" so they are empty if we fail
StrCmp $4 0 fail
StrCmp $5 0 fail
    System::Call 'VERSION::GetFileVersionInfo(tr3,i,ir4,ir5)i.r0'
    StrCmp $0 0 fail
    System::Call 'VERSION::VerQueryValue(ir5,t"\",*i.r6,*i.r7)i.r0'
    StrCmp $0 0 fail
    System::Call '*$6(i,i,i,i,i.r2,i.r1)'
fail:
System::Free $5
Push $1
Push $2
System::Store L
FunctionEnd

Section
!define DllName "$SysDir\ComCtl32.dll"

GetDllVersion "${DllName}" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
DetailPrint 'FileVer: $R2.$R3.$R4.$R5'

Push "${DllName}"
Call GetDllProductVersion
Pop $R0
Pop $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
DetailPrint 'ProdVer: $R2.$R3.$R4.$R5'

SectionEnd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM