NSIS Get Product Version

后端 未结 1 1545
独厮守ぢ
独厮守ぢ 2021-01-16 15:14

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         


        
相关标签:
1条回答
  • 2021-01-16 15:36

    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
    
    0 讨论(0)
提交回复
热议问题