所有
我正在尝试使用NSIS 2.49获取ProductVersion。有没有人有关于如何获得产品版本的例子?
Instrumentation.redefineClass
我已尝试过上述内容,但它只是检索文件版本。
由于
答案 0 :(得分:1)
NSIS没有本机支持,您必须直接调用Windows API:
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