XtInfoPlugin plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.)
m (Added category links.)
Line 90: Line 90:
SectionEnd
SectionEnd
</highlight-nsis>
</highlight-nsis>
[[{{ns:14}}:Plugins]]

Revision as of 21:59, 30 April 2005

Author: jari@razormotion.com (talk, contrib)


Links

Plugin w/ source:

XtInfoPlugin.zip (443 KB)
Zip.gif XtInfoPlugin.zip (443 KB)

Description

xtInfoPlugin determines version information for various components. All ID's are lowercase and no spaces - see in .onInit method.

  • Installer Filename (ie. Setup.exe)
  • Installer FullPath (ie. D:\SetupFiles)
  • Installer FileName (ie. D:\SetupFiles\Setup.exe)
  • Windows Language (ie. Danish, English, German, etc.)
  • .NET Framework IDs (ie. 1.0, 1.1, 2.0, etc.)
  • .NET Framework Version (ie. 1.0.3705, 1.1.4322, etc.)
  • Internet Explorer IDs (ie. 4.01, 5.0, 5.01, 6.0, etc.)
  • Internet Explorer Versions (ie, 5.00.2920.0000, 6.00.2600.0000, etc.)
  • Windows IDs (ie. 95, 98, me, xp, nt3, nt4, 2003, etc)
  • Windows Versions (ie, 5.1.2800, etc.)
  • MDAC IDs (ie. 2.5)
  • MDAC Versions (ie. 2.50.4403.9)
  • OLEDB IDs (ie. 2.5)
  • OLEDB Versions (ie. 2.50.4403.8)
  • Windows Service Pack IDs (ie, 1, 2a, 6a, etc.)

Example (also found in .zip file)

; Download xtInfoPlugin from
; http://www.razormotion.com/nsis/xtInfoPlugin.zip
; best to copy xtInfoPlugin.dll to NSIS\Plugins and remove below code
!addplugindir ".\" ; detect xtInfoPlugin.dll in current directory
!addplugindir "..\" ; detect xtInfoPlugin.dll in parent directory
Name "NSIS xtInfoPlugin-MinimalExample"
OutFile "xtInfoPlugin-MinimalExample.exe"
SetCompress off ; Useful to disable compression under development
!include "${NSISDIR}\Include\MUI.nsh"
!include "${NSISDIR}\Include\LogicLib.nsh"
 
Function .onInit
 
    ; CompareVersion example
    ; (C++)CompareVersion("2.50.4403.9","2.50.4403.9") return 0 (a==b)
    ; (C++)CompareVersion("2.50.4403.9","2.71.9030.0") return 1 (b>a)
    ; (C++)CompareVersion("2.71.9030.0","2.50.4403.9") return -1 (a>b)
 
    StrCpy $2 "2.5"
    Push $2
    xtInfoPlugin::GetMDACVersion
    Pop $1
    Push $1
    xtInfoPlugin::CompareVersion
    Pop $0
    ${if} $0 >= 0
        MessageBox MB_OK "MDAC version is Newer or Equal to $2 (found: $1)"
    ${else}
        MessageBox MB_OK "MDAC version is OLDER than $2 (found: $1)"
    ${endif}
 
    ; ---------------------------------------------------------------------
 
    ; Say we want our application to only work with .NET Framework v1.1
 
    xtInfoPlugin::IsDotNetFrameworkInstalled
    Pop $0
    ${if} $0 == true
        xtInfoPlugin::GetDotNetFrameworkId
        ; GetDotNetFrameworkId (id methods) return x.x and not build info
        Pop $0
        ${if} $0 == "1.1"
            StrCpy $0 "Version 1.1 Installed"
        ${else}
            StrCpy $0 "Version 1.0 Installed"
        ${endif}
    ${else}
        StrCpy $0 "Not installed"
    ${endif}
    xtInfoPlugin::GetDotNetFrameworkVersion
    Pop $1
    MessageBox MB_OK ".NET Framework version check = $0 (found: $1)"
    Quit ; Quit before installer start
 
FunctionEnd
 
; Required by NSIS, we don't need it!
Section
SectionEnd