NSIS 获取产品版本 [英] NSIS Get Product Version

查看:41
本文介绍了NSIS 获取产品版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 NSIS 2.49 获取 ProductVersion.有人有关于如何获取产品版本的示例吗?

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 对此没有原生支持,必须直接调用 Windows API:

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

这篇关于NSIS 获取产品版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆