Check for .NET4.5+ with NSIS

前端 未结 6 1942
暗喜
暗喜 2020-12-28 20:22

All, I am aware of the following methods to check the framework version in NSIS. For .NET4.0+ I currently use

Function IsDotNetInstalled

    StrCpy $0 \"0\         


        
6条回答
  •  天涯浪人
    2020-12-28 20:55

    Here's a simple NSIS Function that checks for .NET versions (works for 4.5, 4.5.1, 4.5.2 and 4.6). The numeric comparisons are based on MSDN.

    Place the function in your NSIS file and invoke it like so

    Call CheckForDotVersion45Up
    Pop $0
    DetailPrint $0
    

    Here is the function.

    ; returns a numeric value on the stack, ranging from 0 to 450, 451, 452 or 460. 0 means nothing found, the other values mean at least that version
    Function CheckForDotVersion45Up
    
      ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" Release
    
      IntCmp $0 393295 is46 isbelow46 is46
    
      isbelow46:
      IntCmp $0 379893 is452 isbelow452 is452
    
      isbelow452:
      IntCmp $0 378675 is451 isbelow451 is451
    
      isbelow451:
      IntCmp $0 378389 is45 isbelow45 is45
    
      isbelow45:
      Push 0
      Return
    
      is46:
      Push 460
      Return
    
      is452:
      Push 452
      Return
    
      is451:
      Push 451
      Return
    
      is45:
      Push 45
      Return
    
    FunctionEnd
    

提交回复
热议问题