XtInfoPlugin plug-in

From NSIS Wiki
Jump to navigationJump to search
Author: jari@razormotion.com (talk, contrib)


Links

Plug-in with C++ source:

Version 1.0.0.1: XtInfoPlugin.zip (443 KB)

Version 1.0.0.2: xtInfoPlugin_v_1.0.0.2.zip (1338 KB)

Description

Version: 1.0.0.1 (13/May/2004)

xtInfoPlugin determines version information for various components. This plug-in can gather the following:

  • 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.)


Version: 1.0.0.2 (15/Dec/2008)

  • Fixed bug in IsAdministrator function. If user belongs to domain with lot of groups, admin rights check fails.

How To Use

All ID's are lowercase and no spaces - see the example with .onInit method (bottom of page).

Functions Reference

xtInfoPlugin::CompareVersion

Compares two version numbers and outputs the result.

Syntax
Push "VersionNumber2"
Push "VersionNumber1"
xtInfoPlugin::CompareVersion
Pop "ResultVar"
Parameters
VersionNumber1, VersionNumber2
Version numbers to compared relating from "VersionNumber1"'s point of view.
ResultVar
Variable where the comparasion result is returned from "VersionNumber1"'s point of view. If "1", "VersionNumber1" is greater than "VersionNumber2", if "0", it is equals to that, and if "-1", it is lesser than that.
Example
    Push "2.5"
    Push "2.81.1117.0"
    xtInfoPlugin::CompareVersion
    Pop $0 ;$0 = "1"

xtInfoPlugin::GetDotNetFrameworkId

Retrieves the ID number for the .NET Framework version installed in the computer.

Syntax
xtInfoPlugin::GetDotNetFrameworkId
Pop "ResultVar"
Parameters
ResultVar
Variable where the .NET Framework's ID number for its version is returned.
Example
xtInfoPlugin::GetDotNetFrameworkId
Pop $0 ;.NET Framework's ID number for its version

xtInfoPlugin::GetDotNetFrameworkVersion

Retrieves the version of .NET Framework, if it is installed in the computer.

Syntax
xtInfoPlugin::GetDotNetFrameworkVersion
Pop "ResultVar"
Parameters
ResultVar
Variable where the version of .NET Framework is returned.
Example
xtInfoPlugin::GetDotNetFrameworkVersion
Pop $0 ;.NET Framework's version

xtInfoPlugin::GetInstaller

Retrieves the installer's file name without its path.

Syntax
xtInfoPlugin::GetInstaller
Pop "ResultVar"
Parameters
ResultVar
Variable where the installer's file name without its path is returned.
Example
xtInfoPlugin::GetInstaller
Pop $0 ;Installer's file name without its path

xtInfoPlugin::GetInstallerFileName

Retrieves the installer's file name with its path.

Syntax
xtInfoPlugin::GetInstallerFileName
Pop "ResultVar"
Parameters
ResultVar
Variable where the installer's file name with its path is returned.
Example
xtInfoPlugin::GetInstallerFileName
Pop $0 ;Installer's file name with its path

xtInfoPlugin::GetInstallerFullPath

Retrieves the path to the installer's file.

Syntax
xtInfoPlugin::GetInstallerFullPath
Pop "ResultVar"
Parameters
ResultVar
Variable where the path to the installer's file is returned.
Example
xtInfoPlugin::GetInstallerFullPath
Pop $0 ;Path to the installer's file

xtInfoPlugin::GetInternetExplorerId

Retrieves the ID number for the Internet Explorer version installed in the computer.

Syntax
xtInfoPlugin::GetInternetExplorerId
Pop "ResultVar"
Parameters
ResultVar
Variable where the Internet Explorer's ID number for its version is returned.
Example
xtInfoPlugin::GetInternetExplorerId
Pop $0 ;Internet Explorer's ID number for its version

xtInfoPlugin::GetInternetExplorerVersion

Retrieves the version of Internet Explorer, if it is installed in the computer.

Syntax
xtInfoPlugin::GetInternetExplorerVersion
Pop "ResultVar"
Parameters
ResultVar
Variable where the version of Internet Explorer is returned.
Example
xtInfoPlugin::GetInternetExplorerVersion
Pop $0 ;Internet Explorer's version

xtInfoPlugin::GetLanguage

Retrieves the Windows system language, if it is installed in the computer.

Syntax
xtInfoPlugin::GetLanguage
Pop "ResultVar"
Parameters
ResultVar
Variable where the Windows system language is returned.
Example
xtInfoPlugin::GetLanguage
Pop $0 ;Windows system language

xtInfoPlugin::GetMDACId

Retrieves the ID number for the MDAC version installed in the computer.

Syntax
xtInfoPlugin::GetMDACId
Pop "ResultVar"
Parameters
ResultVar
Variable where the MDAC's ID number for its version is returned.
Example
xtInfoPlugin::GetMDACId
Pop $0 ;MDAC's ID number for its version

xtInfoPlugin::GetMDACVersion

Retrieves the version of MDAC, if it is installed in the computer.

Syntax
xtInfoPlugin::GetMDACVersion
Pop "ResultVar"
Parameters
ResultVar
Variable where the version of MDAC is returned.
Example
xtInfoPlugin::GetMDACVersion
Pop $1 ;MDAC's version

xtInfoPlugin::GetOLEDBId

Retrieves the ID number for the OLEDB version installed in the computer.

Syntax
xtInfoPlugin::GetOLEDBId
Pop "ResultVar"
Parameters
ResultVar
Variable where the OLEDB's ID number for its version is returned.
Example
xtInfoPlugin::GetOLEDBId
Pop $0 ;OLEDB's ID number for its version

xtInfoPlugin::GetOLEDBVersion

Retrieves the version of OLEDB, if it is installed in the computer.

Syntax
xtInfoPlugin::GetOLEDBVersion
Pop "ResultVar"
Parameters
ResultVar
Variable where the version of OLEDB is returned.
Example
xtInfoPlugin::GetOLEDBVersion
Pop $1 ;OLEDB's version

xtInfoPlugin::GetWindowsId

Retrieves the ID number for the Windows version installed in the computer.

Syntax
xtInfoPlugin::GetWindowsId
Pop "ResultVar"
Parameters
ResultVar
Variable where the Windows's ID number for its version is returned.
Example
xtInfoPlugin::GetWindowsId
Pop $0 ;Windows' ID number for its version

xtInfoPlugin::GetWindowsServicePackId

Retrieves the ID number for the Windows Service Pack version installed in the computer.

Syntax
xtInfoPlugin::GetWindowsServicePackId
Pop "ResultVar"
Parameters
ResultVar
Variable where the Windows Service Pack's ID number for its version is returned.
Example
xtInfoPlugin::GetWindowsServicePackId
Pop $0 ;Windows Service Pack's ID number for its version

xtInfoPlugin::GetWindowsVersion

Retrieves the version of Windows, if it is installed in the computer.

Syntax
xtInfoPlugin::GetWindowsVersion
Pop "ResultVar"
Parameters
ResultVar
Variable where the version of Windows is returned.
Example
xtInfoPlugin::GetWindowsVersion
Pop $1 ;Windows's version

xtInfoPlugin::IsAdministrator

Detects if the current user has administrator rights.

Syntax
xtInfoPlugin::IsAdministrator
Pop "ResultVar"
Parameters
ResultVar
Variable where the string "true" will be outputted if the current user has administrator rights, otherwise it is "false".
Example
xtInfoPlugin::IsAdministrator
Pop $0 ;"true" if the current user has administrator rights, otherwise it is "false"

xtInfoPlugin::IsDotNetFrameworkInstalled

Detects if .NET Framework is installed in the computer.

Syntax
xtInfoPlugin::IsDotNetFrameworkInstalled
Pop "ResultVar"
Parameters
ResultVar
Variable where the string "true" will be outputted if the .NET Framework is installed, otherwise it is "false".
Example
xtInfoPlugin::IsDotNetFrameworkInstalled
Pop $0 ;"true" if it is installed, otherwise it is "false"

xtInfoPlugin::IsDotNetFrameworkInstalled

Detects if .NET Framework is installed in the computer.

Syntax
xtInfoPlugin::IsDotNetFrameworkInstalled
Pop "ResultVar"
Parameters
ResultVar
Variable where the string "true" will be outputted if the .NET Framework is installed, otherwise it is "false".
Example
xtInfoPlugin::IsDotNetFrameworkInstalled
Pop $0 ;"true" if it is installed, otherwise it is "false"

xtInfoPlugin::IsWindowsXXXX

Detects if the XXXX version of Windows is installed in the computer. Replace "XXXX" with either:

  • 95;
  • 98;
  • ME;
  • NT3;
  • NT4;
  • 2000;
  • XP;
  • 2003.
Syntax
xtInfoPlugin::IsWindowsXXXX ;Replace "XXXX" with Windows versions on the list above.
Pop "ResultVar"
Parameters
ResultVar
Variable where the string "true" will be outputted if the specific Windows version is installed, otherwise it is "false".
Example
xtInfoPlugin::IsWindows2003
Pop $0 ;"true" if Windows 2003 is installed, otherwise it is "false"

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