Version plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.)
No edit summary
 
(32 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|TeeWeTee}}
|<small>Author: [[{{ns:2}}:denis_gorbunov|denis_gorbunov]] ([[{{ns:3}}:denis_gorbunov|talk]], [[{{ns:-1}}:Contributions/denis_gorbunov|contrib]])</small>
 
|}
<br style="clear:both;">
== Links ==
== Links ==
Version 0.3 (20. feb 2013)<br>
<attach>NSIS_version_plugin_03.zip</attach> [Adapted version by TeeWeTee]<br>
Version 0.2 (25 sep 2004) [Version by denis_gorbunov]<br>
<attach>NSIS_version_plugin_02.zip</attach><br>
<attach>NSIS_version_plugin_02.zip</attach><br>
[[Image:Zip.gif]] [http://www.mycgiserver.com/~gorbunov/nsis/files/NSIS_version_plugin_02.zip NSIS_version_plugin_02.zip] (35 KB) (Mirror #1)
 
==== Release builds with VS2010 Premium (only older 0.2 release)====
ANSI: http://db.tt/cbyN0KJh
Unicode: http://db.tt/OfllzHW7


== Description ==
== Description ==
Windows OS contain special API for OS version detecting.
With this plugin you are able to determine which version of windows you are running. Technically it is using the GetVersionEx() method from the "kernel32.dll".
But standard NSIS 2 pack not use this.
 
My special plugin "Version.dll" use OS API (function GetVersionEx() from "kernel32.dll") for OS version detecting.
 
Plugin contain function:
*GetWindowsVersion (get major, minor version, build number, platform id, service pack name);
*simply OS detect function (IsWindows31, IsWindows95, IsWindows98, IsWindowsME, IsWindowsNT351, IsWindowsNT40, IsWindows2000, IsWindowsXP, IsWindows2003);
*simply OS platform detect function (IsWindowsPlatformNT, IsWindowsPlatform9x);
*simply "good" OS detect function (IsWindows98orLater);


Size of plugin "version.dll" is 6144 bytes
'''Features:'''
*check for a specific windows version:
**IsWindows95
**IsWindows98
**IsWindowsME
**IsWindowsNT351
**IsWindowsNT40
**IsWindows2000
**IsWindowsXP
**IsWindowsServer2003
**IsWindowsXPx64
**IsWindowsVista
**IsWindowsServer2008
**IsWindows7
**IsWindowsServer2008R2
**IsWindows8
**IsWindowsServer2012
*Call 'GetWindowsVersion' to get all relevant windows versioning infos:
**major version
**minor version
**build number
**platform id
**service pack name
**product type
*Call platform methods to detect the windows platform type:
**IsWindowsPlatformNT
**IsWindowsPlatform9x


== Usage Example ==
== Usage Example ==
<highlight-nsis>
<highlight-nsis>


; if "version.dll" copied in NSIS plugin sub-directory
Name VersionExample
; this line is not necessary
 
!addplugindir "plugins"
 
 
; it is not example
; it is for this empty intallation only
 
OutFile "example_Version_NSIS_plugin.exe"
 
 
Section Dummy
; it is not example
; it is for this empty intallation only
SectionEnd


# Included files
!include Sections.nsh
!include "LogicLib.nsh"


; variables declaration
OutFile "Example_Version_NSIS_plugin.exe"


var TempResult
#Declare variables
var isWindowsXP
var MajorVersion
var MajorVersion
var MinorVersion
var MinorVersion
Line 50: Line 60:
var PlatformID
var PlatformID
var CSDVersion
var CSDVersion
var ProductType


Section -Nope
#Nothing to do here
SectionEnd


Function .onInit
Function .onInit


   ; detect Windows XP
   #detect Windows XP
  ; it is simply
 
  ; call plugin dll function
 
   Version::IsWindowsXP
   Version::IsWindowsXP
 
   #obtain value
   ; get result
   Pop $isWindowsXP
 
    
   Pop $TempResult
   ${if} $isWindowsXP == "1"
 
    MessageBox MB_OK "Its Windows XP!"
   ; check result
   ${Else}
 
    MessageBox MB_OK "Its not Windows XP!"
   StrCmp $TempResult "1" ItIsWindowsXP IsIsNotWindowsXP
   ${EndIf}
 
    
  ItIsWindowsXP:
   #call plugin dll function  
  MessageBox MB_OK "This OS is Windows XP"
   Goto Go2
 
  IsIsNotWindowsXP:
  MessageBox MB_OK "This OS not is Windows XP"
   Goto Go2
 
 
   ; get Windows OS version info
 
   Go2:
 
  ; call plugin dll function  
 
   Version::GetWindowsVersion
   Version::GetWindowsVersion
  ; get result


   Pop $MajorVersion
   Pop $MajorVersion
Line 93: Line 88:
   Pop $PlatformID
   Pop $PlatformID
   Pop $CSDVersion
   Pop $CSDVersion
  Pop $ProductType


   ; show result
   ${if} $ProductType == "1"
   MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion"
    MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion, Workstation"
 
   ${ElseIf} $ProductType == "2"
    MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion, DomainController"
  ${ElseIf} $ProductType == "3"
    MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion, Server"
  ${Else}
    MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion, Unknown ProductType"
  ${EndIf}
  Quit
 
FunctionEnd
FunctionEnd
</highlight-nsis>
</highlight-nsis>
== Version History ==
0.1 (03 sep 2004) (DNG)
* First public release
0.2 (25 sep 2004) (DNG)
* Implemented (proprietary) IntToStr-function since Delphi's SysUtils IntToStr requires more space (+ 24 kilobytes uncompressed)
0.3 (20 feb 2013) (TvT)
* Bugfix: proprietary IntToStr method (from 0.2) is buggy: Returns '6.' instead of '6.0' for Windows Vista (same for W2K 5.0 or NT4.0) Thus using the well testet SysUtils IntToStr method is prefered over some kb in size
*Added further methods for newer windows operating systems:
**IsWindowsXPx64
**IsWindowsVista
**IsWindowsServer2008
**IsWindows7
**IsWindowsServer2008R2
**IsWindows8
**IsWindowsServer2012
*The GetWindowsVersion() method returns the ProductType to be able to differentiate Server and Workstation windows versions
*Removed inexisting (e.g. isWindows31) and useless (e.g. IsWindows98orLater) methods
*Adapted the docs
== Credits ==
Version 0.1 and 0.2 have been developed by Denis Gorbunov (http://gorbunov.ru/). <br>
Version 0.3 was developed by TeeWeTee<br>
[[Category:Plugins]]

Latest revision as of 09:05, 24 April 2014

Author: TeeWeTee (talk, contrib)


Links

Version 0.3 (20. feb 2013)
NSIS_version_plugin_03.zip (69 KB) [Adapted version by TeeWeTee]
Version 0.2 (25 sep 2004) [Version by denis_gorbunov]
NSIS_version_plugin_02.zip (35 KB)

Release builds with VS2010 Premium (only older 0.2 release)

ANSI: http://db.tt/cbyN0KJh Unicode: http://db.tt/OfllzHW7

Description

With this plugin you are able to determine which version of windows you are running. Technically it is using the GetVersionEx() method from the "kernel32.dll".

Features:

  • check for a specific windows version:
    • IsWindows95
    • IsWindows98
    • IsWindowsME
    • IsWindowsNT351
    • IsWindowsNT40
    • IsWindows2000
    • IsWindowsXP
    • IsWindowsServer2003
    • IsWindowsXPx64
    • IsWindowsVista
    • IsWindowsServer2008
    • IsWindows7
    • IsWindowsServer2008R2
    • IsWindows8
    • IsWindowsServer2012
  • Call 'GetWindowsVersion' to get all relevant windows versioning infos:
    • major version
    • minor version
    • build number
    • platform id
    • service pack name
    • product type
  • Call platform methods to detect the windows platform type:
    • IsWindowsPlatformNT
    • IsWindowsPlatform9x

Usage Example

Name VersionExample
 
# Included files
!include Sections.nsh
!include "LogicLib.nsh"
 
OutFile "Example_Version_NSIS_plugin.exe"
 
#Declare variables
var isWindowsXP
var MajorVersion
var MinorVersion
var BuildNumber
var PlatformID
var CSDVersion
var ProductType 
 
 
Section -Nope
#Nothing to do here
SectionEnd
 
Function .onInit
 
  #detect Windows XP
  Version::IsWindowsXP
  #obtain value
  Pop $isWindowsXP
 
  ${if} $isWindowsXP == "1"
    MessageBox MB_OK "Its Windows XP!"
  ${Else}
    MessageBox MB_OK "Its not Windows XP!"
  ${EndIf}
 
  #call plugin dll function 
  Version::GetWindowsVersion

  Pop $MajorVersion
  Pop $MinorVersion
  Pop $BuildNumber
  Pop $PlatformID
  Pop $CSDVersion
  Pop $ProductType
 
  ${if} $ProductType == "1"
    MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion, Workstation"
  ${ElseIf} $ProductType == "2"
    MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion, DomainController"
  ${ElseIf} $ProductType == "3"
    MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion, Server"
  ${Else}
    MessageBox MB_OK "$PlatformID-platform, version $MajorVersion.$MinorVersion, build $BuildNumber, $CSDVersion, Unknown ProductType"
  ${EndIf}
  Quit
 
FunctionEnd

Version History

0.1 (03 sep 2004) (DNG)

  • First public release

0.2 (25 sep 2004) (DNG)

  • Implemented (proprietary) IntToStr-function since Delphi's SysUtils IntToStr requires more space (+ 24 kilobytes uncompressed)

0.3 (20 feb 2013) (TvT)

  • Bugfix: proprietary IntToStr method (from 0.2) is buggy: Returns '6.' instead of '6.0' for Windows Vista (same for W2K 5.0 or NT4.0) Thus using the well testet SysUtils IntToStr method is prefered over some kb in size
  • Added further methods for newer windows operating systems:
    • IsWindowsXPx64
    • IsWindowsVista
    • IsWindowsServer2008
    • IsWindows7
    • IsWindowsServer2008R2
    • IsWindows8
    • IsWindowsServer2012
  • The GetWindowsVersion() method returns the ProductType to be able to differentiate Server and Workstation windows versions
  • Removed inexisting (e.g. isWindows31) and useless (e.g. IsWindows98orLater) methods
  • Adapted the docs

Credits

Version 0.1 and 0.2 have been developed by Denis Gorbunov (http://gorbunov.ru/).
Version 0.3 was developed by TeeWeTee