Get last installed service pack version: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.)
(Added reference to WinVer which effectively replaces this article.)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|alessiog}}
|<small>Author: [[{{ns:2}}:alessiog|alessiog]] ([[{{ns:3}}:alessiog|talk]], [[{{ns:-1}}:Contributions/alessiog|contrib]])</small>
 
|}
'''Note:''' This has been superseded by [http://nsis.sourceforge.net/Include/WinVer.nsh WinVer.nsh], which is included with NSIS 2.21 and greater.  WinVer allows for easy detection of the Windows version using LogicLib macros and has automatic future-support so you can always tell if the system at hand, even if undetected, is newer or older than what you need.
<br style="clear:both;">
 
== Description ==
== Description ==
Here is a simple routine to detect last Service Pack installed on PC.
Here is a simple routine to detect last Service Pack installed on PC.
(modification --[[User:Charlesb|Charlesb]] 09:43, 23 February 2006 (PST): ReadRegStr replaced by ReadRegDWORD; Save $R0 and $R1


== The Function ==
== The Function ==
Line 21: Line 23:
; If no service pack installed returns major ver "0" and minor ver "0"
; If no service pack installed returns major ver "0" and minor ver "0"
; Function tested with Win 95, 98SE, NT4, 2000, XP, 2003 (lang ITA and ENG)
; Function tested with Win 95, 98SE, NT4, 2000, XP, 2003 (lang ITA and ENG)
; $R0, $R1 are NOT saved in stack so you have to preserve them outside this function!


Function GetServicePack
Function GetServicePack
Push $R0
Push $R1


ReadRegStr $R0 HKLM "System\CurrentControlSet\Control\Windows" "CSDVersion"
ReadRegDWORD $R0 HKLM "System\CurrentControlSet\Control\Windows" "CSDVersion"
IntOp $R1 $R0 % 256 ;get minor version
IntOp $R1 $R0 % 256 ;get minor version
Push $R1
IntOp $R0 $R0 / 256 ;get major version
IntOp $R0 $R0 / 256 ;get major version
Push $R0
 
Exch $R1
Exch
Exch $R0
FunctionEnd
FunctionEnd




</highlight-nsis>
</highlight-nsis>
[[Category:Other Products Version Detection Functions]]

Latest revision as of 05:57, 30 November 2011

Author: alessiog (talk, contrib)


Note: This has been superseded by WinVer.nsh, which is included with NSIS 2.21 and greater. WinVer allows for easy detection of the Windows version using LogicLib macros and has automatic future-support so you can always tell if the system at hand, even if undetected, is newer or older than what you need.

Description

Here is a simple routine to detect last Service Pack installed on PC.

(modification --Charlesb 09:43, 23 February 2006 (PST): ReadRegStr replaced by ReadRegDWORD; Save $R0 and $R1

The Function

;-------------------------------------------------------------------------------
; GetServicePack
; Author: Alessio Garbi (e-Project srl) <agarbi@e-project.it> 
;
; input:
;			none
; output:
;    	top of stack: last service pack major version
;    	top of stack-1: last service pack minor version
; note:
;			If no service pack installed returns major ver "0" and minor ver "0"
;			Function tested with Win 95, 98SE, NT4, 2000, XP, 2003 (lang ITA and ENG)
 
Function GetServicePack
	Push $R0
	Push $R1
 
	ReadRegDWORD $R0 HKLM "System\CurrentControlSet\Control\Windows" "CSDVersion"
	IntOp $R1 $R0 % 256			;get minor version
	IntOp $R0 $R0 / 256			;get major version
 
	Exch $R1
	Exch
	Exch $R0
FunctionEnd