;***********************************************************************
; MicroGate Corporation SyncLink Internet Adapter  -  Network Setup File
;***********************************************************************

[Identification]

	OptionType = NetAdapter

;***********************************************************************
;
;***********************************************************************
[PlatformsSupported]

	ISA
	EISA

;***********************************************************************
;
;***********************************************************************

[Options]

	MGSL

;***********************************************************************
;
;***********************************************************************

[FileConstants]

	InfName                 = "OEMMGSL.INF"
	UtilityInf              = "UTILITY.INF"
	ParamInf                = "NCPARAM.INF"
	subroutineinf           = "SUBROUTN.INF"
	SoftwareType            = "driver"
	Exit_Code               = 0

	NetEventDLL             = "%SystemRoot%\System32\Drivers\MGSL.sys"

	Manufacturer            = "MicroGate"

	ProductMajorVersion     = "1"
	ProductMinorVersion     = "2"
	ProductVersion          = $(ProductMajorVersion)"."$(ProductMinorVersion)
	ProductSoftwareName     = "MGSL"
	ProductSoftwareImagePath = "\SystemRoot\System32\drivers\MGSL.sys"

	NetRuleSoftwareType     = "MGSLSys MGSLDriver"
	NetRuleSoftwareUse      = $(SoftwareType)
	NetRuleSoftwareBindForm = """MGSLSys"" yes no container"
	NetRuleSoftwareClass    = {"MGSLDriver basic"}
	NetRuleSoftwareBindable = {"MGSLDriver MGSLAdapter non exclusive 100"}

	ProductHardwareName     = "MGSL"
	NetRuleHardwareBindForm = " yes yes container"
	NetRuleHardwareMGSLType = "MGSL MGSLAdapter"
	NetRuleHardwareMGSLClass = {"MGSLAdapter basic"}
	BindableMGSLTxt         = {"MGSLDriver MGSLAdapter non exclusive 100"}

	TapiDeviceKey           = $(ProductHardwareName)
	TapiMediaType           = "HDLC"

	ProductKeyName          = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"+
     	                     $(ProductSoftwareName)"\CurrentVersion"

	ParamKeyName            = $(!NTN_ServiceBase)"\"$(ProductHardwareName)+
	                          "\Parameters"

	LineType                = 0


;***********************************************************************

[GeneralConstants]

    from                    = ""
    to                      = ""
    ExitCodeOk              = 0
    ExitCodeCancel          = 1
    ExitCodeFatal           = 2
    KeyNull                 = ""
    MAXIMUM_ALLOWED         = 33554432
    RegistryErrorIndex      = NO_ERROR
    KeyProduct              = ""
    KeyParameters           = ""
    TRUE                    = 1
    FALSE                   = 0
    NoTitle                 = 0
    ExitState               = "Active"
    OldVersionExisted       = $(FALSE)
    DriverPath              = $(!STF_NTPATH)\drivers

;***********************************************************************

[Date]

	Now = {} ? $(!LIBHANDLE) GetSystemDate

;***********************************************************************

[Identify]

	Read-Syms Identification

	Set Status     = STATUS_SUCCESSFUL
	Set Identifier = $(OptionType)
	Set Media      = #("Source Media Descriptions", 1, 1)

	Return $(Status) $(Identifier) $(Media)

;***********************************************************************

[ReturnOptions]

	Set Status          = STATUS_FAILED
	Set OptionList      = {}
	Set OptionTextList  = {}
	Set LanguageList    = ^(LanguagesSupported, 1)

	IfContains(i) $($0) in $(LanguageList)
		IfStr(i) $($1) == ""
			GoTo SetOptions
		EndIf

		Set PlatformList = ^(PlatformsSupported, 1)

		IfContains(i) $($1) in $(PlatformList)
			GoTo SetOptions
		Else
			Set Status = STATUS_NOTSUPPORTED
			GoTo ExitReturnOptions
		EndIf
	Else
		Set Status = STATUS_NOLANGUAGE
		GoTo ExitReturnOptions
	EndIf

SetOptions = +
	Set OptionList     = ^(Options, 1)
	Set OptionTextList = ^(OptionsText$($0), 1)
	Set Status         = STATUS_SUCCESSFUL

ExitReturnOptions = +
	Return $(Status) $(OptionList) $(OptionTextList)

;************************************************************************

[InstallOption]

	Set Status   = STATUS_FAILED
	Set Option   = $($1)
	Set SrcDir   = $($2)
	Set RasDir   = $($2)
	Set AddCopy  = $($3)
	Set DoCopy   = $($4)
	Set DoConfig = $($5)
	Set LanguageList = ^(LanguagesSupported, 1)

	IfContains(i) $($0) NOT-IN $(LanguageList)
		Return STATUS_NOLANGUAGE
	EndIf

	Set-Subst LF = "\n"

	Read-Syms GeneralConstants
	Read-Syms FileConstants
	Read-Syms DialogConstants$(!STF_LANGUAGE)

	IfStr(i) $(!NTN_Origination) == "NCPA"
		Set Continue = $(OK)
	EndIf

	Read-Syms FileConstants$(!STF_LANGUAGE)
	Detect Date
	Set-Title  $(FunctionTitle)$(Option)

	Set to   = Begin
	Set from = Begin
	Set CommonStatus = STATUS_SUCCESSFUL

	EndWait

;***********************************************************************

Begin = +
	Shell "" MgGetSysVersion
	set WinNTSystemMajorVersion = $($R0)

	IfStr(i) $(!NTN_InstallMode) == "deinstall"

		Set StartLabel = RemoveAdapter

	Else-IfStr(i) $(!NTN_InstallMode) == "update"

		Set StartLabel = UpgradeSoftware

	Else-IfStr(i) $(!NTN_InstallMode) == "bind"

		Set StartLabel = BindingAdapter

	Else-IfStr(i) $(!NTN_InstallMode) == "configure"

		Set StartLabel = ConfigureAdapter
		Set CommonStatus = STATUS_REBOOT

		IfStr(i) $(ProductKeyName) == $(!NTN_RegBase)

			;* The user is trying to configure the driver software
			;* instead of the hardware adapter instance.

			Debug-Output $(InfName)": Cannot configure the driver software."
			Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE

			IfInt $($ShellCode) != $(!SHELL_CODE_OK)
				Debug-Output $(InfName)": ShellCode error: cannot get an error string."
				GoTo ShellCodeError
			EndIf

			Set Error = $($R0)
			Set from = end
			Set to = end
			GoTo NonFatalInfo
		EndIf
	Else
		Set StartLabel = InstallAdapter
		Set OEM_ABANDON_OPTIONS = {}
		Set OEM_ABANDON_SOFTWARE = FALSE
		Set OEM_ABANDON_ON = TRUE
	EndIf

	Shell "" SetAdapterDefaults
	Set AdapterNumber = 0
	Set BaseAddr = $($R0)
	Set IrqLevel = $($R1)
	Set DmaLevel = $($R2)
	Set ConnectType = $($R3)
	Set ConnectIndicator = $($R4)
	Set Encoding = $($R5)
	Set ConstantRTS = $($R6)
	Set InitString = $($R7)
	Set ExternalClockingSpeed = $($R8)
	Set LinkSpeed = $($R9)

	Set from = FatalError
	Set to = FatalError

	GoTo $(StartLabel)

;***********************************************************************

InstallAdapter = +

	;*
	;* Attempt to open a key to the product key name registry entry.
	;*

	OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

	IfStr $(KeyProduct) != $(KeyNull)

		;* The product key name registry entry already exists so 
		;* at least one instance of the product is already installed.

		CloseRegKey $(KeyProduct)

		IfStr(i) !(NTN_RegBase) == $(ProductKeyName)

			;* Installing new driver software.

			Shell $(UtilityInf), VerExistedDlg, $(ProductSoftwareTitle), $(ProductVersion)

			IfInt $($ShellCode) != $(!SHELL_CODE_OK)
				Debug-Output $(InfName)": ShellCode error: cannot get an error string."
				GoTo ShellCodeError
			EndIf

			GoTo end
		Else
			;* Installing additional adapter instance.

			Set OldVersionExisted = $(TRUE)
		EndIf
	EndIf

	Shell "" SetAdapterDefaults
	Set AdapterNumber = 0
	Set BaseAddr = $($R0)
	Set IrqLevel = $($R1)
	Set DmaLevel = $($R2)
	Set ConnectType = $($R3)
	Set ConnectIndicator = $($R4)
	Set Encoding = $($R5)
	Set ConstantRTS = $($R6)
	Set InitString = $($R7)
	Set ExternalClockingSpeed = $(R8)
	Set LinkSpeed = $($R9)

	GoTo AdapterSetup

;*************************************************************************

ConfigureAdapter = +

	IfStr $(KeyProduct) == $(KeyNull)

		;* NTN_RegBase = 
		;* 	SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\n
		;* where n = adapter number
		;*
		;* This key contains the ProductName and ServiceName
		;* for this adapter instance.

		OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) KeyProduct

		IfStr $(KeyProduct) == $(KeyNull)
			Set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
			Debug-Output $(InfName)": Cannot find component product key"
			GoTo FatalRegistry
		EndIf
	EndIf



	;* Call the FindService function to get a key to the
	;* service registery entry. If everything works OK then
	;* the returned registry keys (R1,R2) are already open.
	;*
	;* $($R0) = Registry Error Index
	;* $($R1) = Key to Service registry entry
	;* $($R2) = Key to Service Parameters register entry

	Shell $(UtilityInf) FindService, $(KeyProduct)

	IfInt $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output $(InfName)": FindService shell failure"
		GoTo ShellCodeError
	EndIf

	IfStr(i) $($R0) != NO_ERROR
		Debug-Output $(InfName)": FindService Shell error: "$($R0)
		GoTo FatalRegistry
	EndIf


	;* Save the service parameters registry key and close the
	;* service base registry key.

	Set KeyParameters = $($R2)
	CloseRegKey $($R1)

	IfStr $(KeyParameters) == $(KeyNull)
		Set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
		Debug-Output $(InfName)": Cannot find component service"
		GoTo FatalRegistry
	EndIf


	;*
	;* If we get to here we know there exists an instance of
	;* this hardware component.
	;*

	Set OldVersionExisted = $(TRUE)
	Set ValueName = ""
	Set ValueData = ""
	Set ValueStr  = ""
	Set ValueList = {}


	;*
	;* Get a list of all parameter values located in the
	;* serivce parameters registry entry for the adapter instance. 
	;* Parse the values into script variable so they can be manipulated.
	;*

	EnumRegValue $(KeyParameters) ValueList

	ForListDo $(ValueList)

		Set ValueItem = $($)
		Set ValueName = *($(ValueItem),1)
		Set ValueData = *($(ValueItem),4)

		Debug-Output $(InfName)": "$(ValueName)"="$(ValueData)

		IfStr(i) $(ValueName) == "BaseAddr"
			Set BaseAddr = $(ValueData)
		Else-IfStr(i) $(ValueName) == "DmaLevel"
			Set DmaLevel = $(ValueData)
		Else-IfStr(i) $(ValueName) == "IrqLevel"
			Set IrqLevel = $(ValueData)
		Else-IfStr(i) $(ValueName) == "LineType"
			Set LineType = $(ValueData)
		Else-IfStr(i) $(ValueName) == "ConnectType"
			Set ConnectType = $(ValueData)
		Else-IfStr(i) $(ValueName) == "ConstantRTS"
			Set ConstantRTS = $(ValueData)
		Else-IfStr(i) $(ValueName) == "ConnectIndicator"
			Set ConnectIndicator = $(ValueData)
		Else-IfStr(i) $(ValueName) == "InitString"
			Set InitString = $(ValueData)
		Else-IfStr(i) $(ValueName) == "Encoding"
			Set Encoding = $(ValueData)
		Else-IfStr(i) $(ValueName) == "ExternalClockingSpeed"
			set ExternalClockingSpeed = $(ValueData)
		Else-IfStr(i) $(ValueName) == "LinkSpeed"
			set LinkSpeed = $(ValueData)
		Else-IfStr(i) $(ValueName) == "BusNumber"
			set BusNumber = $(ValueData)
		Else-IfStr(i) $(ValueName) == "BusType"
			set BusType = $(ValueData)
		Else-IfStr(i) $(ValueName) == "AddressList"
			set TapiAddressList = $(ValueData)
		Else-IfStr(i) $(ValueName) == "AdapterNumber"
			Set AdapterNumber = $(ValueData)
		EndIf

	EndForListDo

;***********************************************************************

AdapterSetup = +

	Set from = AdapterOptions

;***********************************************************************

AdapterOptions = +

	Read-Syms FileDependentDlg$(!STF_LANGUAGE)

	set MGSLLIBHANDLE = ""

	IfInt $(WinNTSystemMajorVersion) < 4
		set DLLLibName = "mgslset3.dll"
	Else
		set DLLLibName = "mgslset.dll"
	EndIf

	LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\"$(DLLLibName)

	IfStr(i) $(STATUS) == "NO"
		LoadLibrary "x" $(SrcDir)"\"$(DLLLibName) MGSLLIBHANDLE 
	Else
		LoadLibrary "x" $(!STF_WINDOWSSYSPATH)"\"$(DLLLibName) MGSLLIBHANDLE 
	EndIf


	Set CallResult = ""

	LibraryProcedure CallResult $(MGSLLIBHANDLE) GetMgWanConfig +
		$(AdapterNumber) +
		$(BaseAddr) +
		$(IrqLevel) +
		$(DmaLevel) +
		$(ConnectType) +
		$(ConnectIndicator) +
		$(Encoding) +
		$(ConstantRTS) +
		$(InitString) +
		$(ExternalClockingSpeed) +
		$(LinkSpeed) +
		$(SrcDir)

	IfStr(i) $(CallResult) == ""
		Set CommonStatus = STATUS_USERCANCEL
		GoTo end
	EndIf

	Set BaseAddr = *($(CallResult),1)
	Set IrqLevel = *($(CallResult),2)
	Set DmaLevel = *($(CallResult),3)
	Set ConnectType = *($(CallResult),4)
	Set ConnectIndicator = *($(CallResult),5)
	Set Encoding = *($(CallResult),6)
	Set ConstantRTS = *($(CallResult),7)
	Set InitString = *($(CallResult),8)
	Set ExternalClockingSpeed = *($(CallResult),9)
	Set LinkSpeed = *($(CallResult),10)

	FreeLibrary $(MGSLLIBHANDLE)
	set MGSLLIBHANDLE = ""

	IfStr(i) $(!STF_NCDETINFO) == {}

		Shell $(UtilityInf),GetBusTypeDialog,$(ProductHardware$(Option)Description) $(BusType) $(BusNumber)

		ifInt $($ShellCode) != $(!SHELL_CODE_OK)
			Debug-Output $(InfName)": ShellCode error."
			GoTo ShellCodeError
		EndIf

		Set BusType = $($R1)
		Set BusNumber = $($R2)

	Else
		Set BusType = *($(!STF_NCDETINFO),5)
		Set BusNumber = *($(!STF_NCDETINFO),6)
	EndIf

;************************************************************************

SkipOptions =+

	IfInt $(OldVersionExisted) == $(TRUE)
		IfStr(i) $(!NTN_InstallMode) == configure
			GoTo WriteParameters
		EndIf
	EndIf

	StartWait

	IfInt $(OldVersionExisted) == $(FALSE)
		IfStr(i) $(!NTN_InstallMode) == "install"
			IfStr(i) $(DoCopy) == "YES"

				LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\MGSLSET.DLL"

				IfStr(i) $(STATUS) == "YES"
					Set SrcDir = $(!STF_WINDOWSSYSPATH)
				Else
					Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) YES

					IfInt $($ShellCode) != $(!SHELL_CODE_OK)
						GoTo ShellCodeError
					Else-IfStr(i) $($R0) == STATUS_FAILED
						Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"

						IfInt $($ShellCode) != $(!SHELL_CODE_OK)
							GoTo ShellCodeError
						EndIf

						Set Error = $($R0)
						GoTo FatalError
					Else-IfStr(i) $($R0) == STATUS_USERCANCEL
						GoTo SuccessfulOption
					EndIf

					Set SrcDir = $($R1)
				EndIf
			EndIf

			Install "Install-Option"

			IfStr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
				Shell $(UtilityInf) RegistryErrorString "UNABLE_COPY_FILE"

				IfInt $($ShellCode) != $(!SHELL_CODE_OK)
					GoTo ShellCodeError
				EndIf

				Set Error = $($R0)
				GoTo FatalError
			EndIf
		EndIf

		;*
		;* Add the driver software component.
		;*

		Shell $(UtilityInf), AddSoftwareComponent, $(Manufacturer), +
			$(ProductSoftwareName), +
			$(ProductSoftwareName), +
			$(ProductSoftwareTitle), $(STF_CONTEXTINFNAME), +
			$(ProductSoftwareImagePath), "kernelautostart", "NDIS", {}, "",+
			$(NetEventDLL)

		Set OEM_ABANDON_SOFTWARE = TRUE

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			Debug-Output $(InfName)": ShellCode error"
			GoTo ShellCodeError
		EndIf

		Set RegistryErrorIndex = $($R0)
		Set KeyProduct      = $($R1)
		Set SoftNetRulesKey = $($R2)

		CloseRegKey $($R3)
		CloseRegKey $($R4)
		CloseRegKey $($R5)

		IfStr(i) $(RegistryErrorIndex) != NO_ERROR
			EndWait
			Debug-Output $(InfName)": Registry error: add software components"
			CloseRegKey $(KeyProduct)
			CloseRegKey $(SoftNetRulesKey)
  			GoTo FatalRegistry
		EndIf

		Set NewValueList = {{SoftwareType,$(NoTitle),$(!REG_VT_SZ),$(SoftwareType)},+
				{MajorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMajorVersion)},+
				{MinorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersion)},+
				{Title,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareTitle)},+
				{Description,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareDescription)},+
				{ServiceName,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareName)},+
				{InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}

		Shell  $(UtilityInf), AddValueList, $(KeyProduct), $(NewValueList)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			Debug-Output $(InfName)": ShellCode error."
			GoTo ShellCodeError
		EndIf

		Set RegistryErrorIndex = $($R0)

		IfStr(i) $(RegistryErrorIndex) != NO_ERROR
			EndWait
			Debug-Output $(InfName)": Registry error: add value list."
			CloseRegKey $(KeyProduct)
			CloseRegKey $(SoftNetRulesKey)
			GoTo FatalRegistry
		EndIf

		Set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareType)},+
				{use,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareUse)}, +
				{bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareBindForm)}, +
				{class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareClass)}, +
				{bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(Bindable$(Option)Txt)}, +
				{InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}

		Shell  $(UtilityInf), AddValueList, $(SoftNetRulesKey), $(NewValueList)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			Debug-Output $(InfName)": ShellCode error."
			GoTo ShellCodeError
		EndIf

		Set RegistryErrorIndex = $($R0)

		CloseRegKey $(KeyProduct)
		CloseRegKey $(SoftNetRulesKey)

		IfStr(i) $(RegistryErrorIndex) != NO_ERROR
			EndWait
			Debug-Output $(InfName)": Resgitry error: add value list."
			GoTo FatalRegistry
		EndIf
	EndIf


	;*
	;* Add new hardware component instance to registry.
	;*

	Shell $(UtilityInf), AddHardwareComponent, $(ProductHardwareName), +
			$(STF_CONTEXTINFNAME),$(ProductKeyName)

	IfInt $($R4) != -1
		Set OEM_ABANDON_OPTIONS = >($(OEM_ABANDON_OPTIONS), $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards\"$($R4))
	EndIf

	IfInt $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output $(InfName)": Cannot add hardware component"
		GoTo ShellCodeError
	EndIf

	Set RegistryErrorIndex = $($R0)

	IfStr(i) $(RegistryErrorIndex) != NO_ERROR
		EndWait
		Debug-Output $(InfName)": Registry error: add hardware component"
		CloseRegKey $($R1)
		CloseRegKey $($R2)
		CloseRegKey $($R3)
		GoTo FatalRegistry
	EndIf

	Set KeyParameters = $($R3)
	Set KeyAdapterRules = $($R2)
	Set AdapterNumber = $($R4)

	Set NewValueList = {{Manufacturer,$(NoTitle),$(!REG_VT_SZ),$(Manufacturer)},+
					{Title,$(NoTitle),$(!REG_VT_SZ),"["$($R4)"] "$(ProductHardware$(Option)Title)},+
					{Description,$(NoTitle),$(!REG_VT_SZ),$(ProductHardware$(Option)Description)},+
					{ProductName,$(NoTitle),$(!REG_VT_SZ),$(ProductHardwareName)},+
					{ServiceName,$(NoTitle),$(!REG_VT_SZ),$($R5)},+
					{InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}

	Shell  $(UtilityInf), AddValueList, $($R1), $(NewValueList)

	IfInt $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output $(InfName)": ShellCode error"
		GoTo ShellCodeError
	EndIf

	CloseRegKey $($R1)


	Set TempProdName = """"$(ProductHardwareName)$(AdapterNumber)""""
	Set TempBindForm = $(TempProdName)$(NetRuleHardwareBindForm)
	Set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRuleHardware$(Option)Type)},+
					{bindform,$(NoTitle),$(!REG_VT_SZ),$(TempBindForm)}, +
					{class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleHardware$(Option)Class)}, +
					{InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}

	Shell  $(UtilityInf), AddValueList, $(KeyAdapterRules), $(NewValueList)

	IfInt $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output $(InfName)": ShellCode error."
		GoTo ShellCodeError
	EndIf

	Set RegistryErrorIndex = $($R0)

	IfStr(i) $(RegistryErrorIndex) != NO_ERROR
		EndWait
		Debug-Output $(InfName)": Resgitry error: add value list."
		CloseRegKey $(KeyParameters)
		CloseRegKey $(KeyAdapterRules)
		GoTo FatalRegistry
	EndIf

	CloseRegKey $(KeyAdapterRules)

	GoTo WriteParameters

;************************************************************************

WriteParameters = +

	;*
	;* AdapterNumber is obtained by calling the AddHardwareComponent
	;* function. This does not get called on configuration so 
	;* AdapterNumber is empty and a bad AddressList is written back.
	;*

	Set TapiAddressList = {$(AdapterNumber)" 1 0"}

	Set NewValueList = {+
			{AddressList,$(NoTitle),$(!REG_VT_MULTI_SZ),$(TapiAddressList)},+
			{BusNumber,$(NoTitle),$(!REG_VT_DWORD),$(BusNumber)},+
			{BusType,$(NoTitle),$(!REG_VT_DWORD),$(BusType)},+
			{DeviceName,$(NoTitle),$(!REG_VT_SZ),$(ProductHardwareName)},+
			{IrqLevel,$(NoTitle),$(!REG_VT_DWORD),$(IrqLevel)},+
			{DmaLevel,$(NoTitle),$(!REG_VT_DWORD),$(DmaLevel)},+
			{LineType,$(NoTitle),$(!REG_VT_DWORD),$(LineType)},+
			{ConnectType,$(NoTitle),$(!REG_VT_DWORD),$(ConnectType)},+
			{MediaType,$(NoTitle),$(!REG_VT_SZ),$(TapiMediaType)},+
			{BaseAddr,$(NoTitle),$(!REG_VT_DWORD),$(BaseAddr)},+
			{ConstantRTS,$(NoTitle),$(!REG_VT_DWORD),$(ConstantRTS)},+
			{ConnectIndicator,$(NoTitle),$(!REG_VT_DWORD),$(ConnectIndicator)},+
			{Encoding,$(NoTitle),$(!REG_VT_DWORD),$(Encoding)},+
			{InitString,$(NoTitle),$(!REG_VT_SZ),$(InitString)},+
			{ExternalClockingSpeed,$(NoTitle),$(!REG_VT_DWORD),$(ExternalClockingSpeed)},+
			{LinkSpeed,$(NoTitle),$(!REG_VT_DWORD),$(LinkSpeed)},+
			{AdapterNumber,$(NoTitle),$(!REG_VT_DWORD),$(AdapterNumber)}+
			}


	Shell  $(UtilityInf), AddValueList, $(KeyParameters), $(NewValueList)

	CloseRegKey $(KeyParameters)

	IfInt $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output $(InfName)": ShellCode error."
		GoTo ShellCodeError
	EndIf

	Set RegistryErrorIndex = $($R0)

	IfStr(i) $(RegistryErrorIndex) != NO_ERROR
		Debug-Output $(InfName)": Registry error: Add value list"
		GoTo FatalRegistry
	EndIf

	;*------------------------------------------
	;* Skip TAPI/RAS setup if already installed.
	;*------------------------------------------

	IfStr(i) $(!NTN_InstallMode) == configure
		GoTo SuccessfulOption
	EndIf

	;*----------------------------------------------------
	;* Create the HARDWARE\DEVICEMAP\TAPI DEVICES\MGSL key
	;*----------------------------------------------------

	OpenRegKey $(!REG_H_LOCAL) "" "HARDWARE\DEVICEMAP" $(MAXIMUM_ALLOWED) BaseKey

	shell "" MgCreateRegKey $(BaseKey) "TAPI DEVICES\MGSL"

	IfStr(i) $($R0) != NO_ERROR
		Debug-Output $(InfName)": Error creating registry key!"
		GoTo FatalRegistry
	EndIf

	Set TapiDeviceKey = $($R1)

	;*
	;* Get the current address list
	;*

	GetRegValue $(TapiDeviceKey) "Address" OldAddressList

	IfStr(i) $(OldAddressList) != ""
		Set TmpAddressList = >(*($(OldAddressList),4),*($(TapiAddressList),1))
		Set TapiAddressList = $(TmpAddressList)

		Debug-Output $(InfName)": Old    ="*($(OldAddressList),4)
		Debug-Output $(InfName)": Tmp    ="$(TmpAddressList)
		Debug-Output $(InfName)": Address="$(TapiAddressList)
	EndIf

	Set NewValueList = +
		{{Address,$(NoTitle),$(!REG_VT_MULTI_SZ),$(TapiAddressList)}, +
		{"Media Type",$(NoTitle),$(!REG_VT_SZ),$(TapiMediaType)} }

	Shell  $(UtilityInf), AddValueList, $(TapiDeviceKey), $(NewValueList)

	IfInt $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output $(InfName)": ShellCode error."
		GoTo ShellCodeError
	EndIf

	Set RegistryErrorIndex = $($R0)

	IfStr(i) $(RegistryErrorIndex) != NO_ERROR
		Debug-Output $(InfName)": Registry error: Add value list"
		GoTo FatalRegistry
	EndIf

	CloseRegKey $(TapiDeviceKey)
	CloseRegKey $(BaseKey)


	;*------------------------------------------------------------
	;* If RAS is not installed then shell ras setup INF file to 
	;* install RAS else invoke RAS to allow user to configure RAS.
	;*------------------------------------------------------------

	Read-Syms InvokeRasDlg$(!STF_LANGUAGE)

	Shell "oemnsvra.inf" CheckRasInstalled

	IfInt $($ShellCode) != $(!SHELL_CODE_OK)

		Debug-Output $(InfName)": Error Shelling the RAS INF file oemnsvra.inf" 

		Shell "subroutn.inf" SetupMessage, $(!STF_LANGUAGE),  +
			"STATUS", $(InvokeRasError)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			GoTo ShellCodeError
		EndIf
		GoTo SuccessfulOption
	EndIf

	Set RasInstalled = $($R0)
	Debug-Output $(InfName)": Is RAS Installed? "$(RasInstalled)


	;*-----------------------------------------------------------------
	;* display a message to the user that RAS setup will now be invoked
	;*-----------------------------------------------------------------

	IfStr(i) $(RasInstalled) == FALSE

		Shell "subroutn.inf" SetupMessage, $(!STF_LANGUAGE), "STATUS", +
			$(InvokeRasSetupMsg)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			GoTo SuccessfulOption
		EndIf
	Else
		Shell "subroutn.inf" SetupMessage, $(!STF_LANGUAGE), "STATUS", +
			$(InvokeRasConfigMsg)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			GoTo SuccessfulOption
		EndIf
	EndIf


	;-----------------------------------------------------------
	; Set the flags based on whether this is an IDW installation
	;-----------------------------------------------------------

	IfStr(i) $(!STF_IDW) == TRUE
		Set AddCopy  = NO
		Set DoCopy   = NO
		Set DoConfig = NO
	Else
		Set AddCopy  = YES
		Set DoCopy   = YES
		Set DoConfig = YES
	EndIf


	;*----------------------------------------------------
	;* Change the global install mode flag to configure if 
	;* RAS is already installed
	;*----------------------------------------------------

	IfStr(i) $(RasInstalled) == TRUE
		Set SaveNTN_InstallMode = $(!NTN_InstallMode)
		Set !NTN_InstallMode = configure
	EndIf


	;*-------------------------------------------
	;* now invoke RAS setup to do the right thing
	;*-------------------------------------------

	set !STF_SRCDIR_OVERRIDE = ""

	Shell "oemnsvra.inf" InstallOption $(!STF_LANGUAGE) "RAS" $(RasDir) $(AddCopy) $(DoCopy) $(DoConfig)


	;*------------------------------------------------------
	;* restore the global instal mode flag if it was changed
	;*------------------------------------------------------

	IfStr(i) $(RasInstalled) == TRUE
		Set !NTN_InstallMode = $(SaveNTN_InstallMode)
	EndIf

	IfInt $($ShellCode) != $(!SHELL_CODE_OK)

		Debug-Output $(InfName)": Error Shelling the RAS INF file oemnsvra.inf" 

		Shell "subroutn.inf" SetupMessage, $(!STF_LANGUAGE), "STATUS",  +
			$(InvokeRasError)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			GoTo ShellCodeError
		EndIf

		GoTo SuccessfulOption
	EndIf

	EndWait
	GoTo SuccessfulOption

;***********************************************************************

BindingAdapter =+

	Set Error = "Binding: Sorry, not yet implemented."
	GoTo FatalError

;*****************************************************************************

RemoveAdapter = +

	IfStr(i) $(ProductKeyName) == $(!NTN_RegBase)

		Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
			$(ProductSoftwareName)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			Debug-Output $(InfName)": ShellCode error"
			GoTo ShellCodeError
		EndIf

		Set RegistryErrorIndex = $($R0)

		IfStr(i) $(RegistryErrorIndex) != NO_ERROR
			GoTo FatalRegistry
		EndIf

	Else

		Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
			$(ProductSoftwareName), $(!NTN_RegBase)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			Debug-Output $(InfName)": ShellCode error"
			GoTo ShellCodeError
		EndIf

		Set RegistryErrorIndex = $($R0)

		IfStr(i) $(RegistryErrorIndex) != NO_ERROR
			GoTo FatalRegistry
		EndIf

	EndIf

	GoTo end

;*****************************************************************************

UpgradeSoftware = +

	IfStr(i) $(ProductKeyName) == $(!NTN_RegBase)

		OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

		IfStr $(KeyProduct) != $(KeyNull)

			GetRegValue $(KeyProduct),"MajorVersion", VersionInfo
			Set Version = *($(VersionInfo), 4)

			Shell $(UtilityInf), GetInfFileNameFromRegistry, $(KeyProduct)

			IfInt $($ShellCode) != $(!SHELL_CODE_OK)
				Debug-Output $(InfName)": ShellCode error"
				GoTo ShellCodeError
			EndIf

			Set !UG_Filename = $($R0)

			IfStr(i) $(!UG_Filename) != ""

				install "Install-Update"

				IfStr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
					GoTo FatalError
				EndIf
			EndIf

			SetRegValue $(KeyProduct) {MajorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMajorVersion)}
			SetRegValue $(KeyProduct) {MinorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMinorVersion)}

			IfInt $(Version) != $(ProductVersion)
			EndIf

			CloseRegKey $(KeyProduct)
		Else
			GoTo FatalRegistry
		EndIf

	Else

		OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) +
			$(MAXIMUM_ALLOWED) NetworkCardKey

		IfStr(i) $(NetworkCardKey) != $(KeyNull)

			GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
			Set ServiceName = *($(ServiceNameInfo), 4)
			OpenRegKey $(NetworkCardKey) "" "NetRules" $(MAXIMUM_ALLOWED) NetRuleKey

			IfStr(i) $(NetRuleKey) == $(KeyNull)
				GoTo FatalRegistry
			EndIf

			CloseRegKey $(NetRules)
			CloseRegKey $(NetworkCardKey)
		Else
			GoTo FatalRegistry
		EndIf

		OpenRegKey $(!REG_H_LOCAL) "" +
				$(!NTN_ServiceBase)"\"$(ServiceName) +
				$(MAXIMUM_ALLOWED) ServiceKey

		IfStr(i) $(ServiceKey) != $(KeyNull)
			CloseRegKey $(ServiceKey)
		Else
			GoTo FatalRegistry
		EndIf
	EndIf

	GoTo end

;***********************************************************************

SuccessfulOption = +

    GoTo end

;***********************************************************************

Abandon = +

	ForListDo $(OEM_ABANDON_OPTIONS)

		Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
			$(ProductSoftwareName), $($)

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			Debug-Output $(InfName)": ShellCode error"
			GoTo ShellCodeError
		EndIf

		Set RegistryErrorIndex = $($R0)

		IfStr(i) $(RegistryErrorIndex) != NO_ERROR
			GoTo FatalRegistry
		EndIf

	EndForListDo


	IfStr(i) $(OEM_ABANDON_SOFTWARE) == TRUE

		Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
			$(ProductSoftwareName), FALSE

		IfInt $($ShellCode) != $(!SHELL_CODE_OK)
			Debug-Output $(InfName)": ShellCode error"
			GoTo ShellCodeError
		EndIf

		Set RegistryErrorIndex = $($R0)

		IfStr(i) $(RegistryErrorIndex) != NO_ERROR
			GoTo FatalRegistry
		EndIf

	EndIf

	GoTo end

;***********************************************************************

WarningMsg = +
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "WARNING", $(Error)
    IfInt $($ShellCode) != $(!SHELL_CODE_OK)
        GoTo ShellCodeError
    EndIf
    IfStr(i) $($R1) == "OK"
        GoTo $(to)
    Else-IfStr(i) $($R1) == "CANCEL"
        GoTo $(from)
    EndIf
    GoTo end

;***********************************************************************

NonFatalInfo = +
    Set Severity = STATUS
    Set CommonStatus = STATUS_USERCANCEL
    IfStr(i) $(Error) == ""
        Set Severity = NONFATAL
        Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
        IfInt $($ShellCode) != $(!SHELL_CODE_OK)
            GoTo ShellCodeError
        EndIf
        Set Error = $($R0)
    EndIf
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), $(Severity), $(Error)
    IfInt $($ShellCode) != $(!SHELL_CODE_OK)
        GoTo ShellCodeError
    EndIf
    IfStr(i) $($R1) == "OK"
        GoTo $(from)
    EndIf
    GoTo end

;***********************************************************************

FatalRegistry = +
    Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
    IfInt $($ShellCode) != $(!SHELL_CODE_OK)
        GoTo ShellCodeError
    EndIf
    Set Error = $($R0)
    GoTo FatalError

;***********************************************************************

FatalDetect = +
    Shell $(UtilityInf),RegistryErrorString,CANNOT_DETECT
    IfInt $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output $(InfName)": ShellCode error: cannot get an error string."
        GoTo ShellCodeError
    EndIf
    Set Error = $($R0)
    GoTo FatalError

;***********************************************************************

FatalError = +
    IfStr(i) $(Error) == ""
        Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
        IfInt $($ShellCode) != $(!SHELL_CODE_OK)
            GoTo ShellCodeError
        EndIf
        Set Error = $($R0)
    EndIf
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
    IfInt $($ShellCode) != $(!SHELL_CODE_OK)
        GoTo ShellCodeError
    EndIf
    GoTo SetFailed

;***********************************************************************

ShellCodeError = +
    Set DlgType      = "MessageBox"
    Set STF_MB_TITLE = $(ShellCodeErrorTitle)
    Set STF_MB_TEXT  = $(ShellCodeErrorText)
    Set STF_MB_TYPE  = 1
    Set STF_MB_ICON  = 3
    Set STF_MB_DEF   = 1
    UI Start "Error Message"
    GoTo SetFailed

;***********************************************************************

SetFailed = +
    Set CommonStatus = STATUS_FAILED
    IfStr(i) $(OEM_ABANDON_ON) == TRUE
        Set OEM_ABANDON_ON = FALSE
        GoTo Abandon
    EndIf
    GoTo end

;***********************************************************************

end = +
    Return $(CommonStatus)

;*****************************************************************************

[MgCreateRegKey]

	Set ECR_Result          = NO_ERROR
	Set ECR_BaseKeyHandle   = $($0)
	Set ECR_NewPath         = $($1)
	Set KeyNull             = ""
	Set MAXIMUM_ALLOWED     = 33554432

	OpenRegKey $(ECR_BaseKeyHandle) "" $(ECR_NewPath) $(MAXIMUM_ALLOWED) ECR_BaseKey

	IfStr $(ECR_BaseKey) != $(KeyNull)
		Set ECR_KeyHandle = $(ECR_BaseKey)
		GoTo  ECR_Return
	EndIf

	Set ECR_TmpPath = ""
	Split-String $(ECR_NewPath) "\" ECR_PList

	ForListDo $(ECR_PList)
		IfStr(i) $($) != "\"
			IfInt $(#) == 1
				Set ECR_TmpPath = $($)
			Else
				Set ECR_TmpPath = $(ECR_TmpPath)"\"$($)
			EndIf

			OpenRegKey $(ECR_BaseKeyHandle) "" $(ECR_TmpPath) $(MAXIMUM_ALLOWED) ECR_BaseKey

			IfStr $(ECR_BaseKey) == $(KeyNull)
				CreateRegKey $(ECR_BaseKeyHandle)  {$(ECR_TmpPath),0,GenericClass} "" $(MAXIMUM_ALLOWED) "" ECR_KeyHandle
				IfStr(i) $(ECR_KeyHandle) == $(KeyNull)
					Set ECR_Result = $($R0)
					GoTo ECR_Return
				EndIf
			EndIf
		EndIf
	EndForListDo

ECR_Return = +
	Return $(ECR_Result) $(ECR_KeyHandle)

;***********************************************************************

[Install-Option]

	Debug-Output $(InfName)": Install-Option install section"
	Debug-Output $(InfName)": SrcDir="$(SrcDir)

	Set STF_VITAL = ""
	Set STF_OVERWRITE = "VERIFYSOURCEOLDER"

	IfStr(i) $(AddCopy) == "YES"
		IfInt $(WinNTSystemMajorVersion) < 4
			AddSectionFilesToCopyList Files-$(Option)3 $(SrcDir) $(!STF_WINDOWSSYSPATH)
		Else
			AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)
		EndIf
	EndIf

	IfStr(i) $(DoCopy) == "YES"
		Set !STF_NCPA_FLUSH_COPYLIST = TRUE
		CopyFilesInCopyList
	EndIf

	Exit

;***********************************************************************

[Install-Update]

	Debug-Output $(InfName)": Install-Update install section"
	Debug-Output $(InfName)": SrcDir="$(SrcDir)

	Set STF_VITAL     = ""
	Set STF_OVERWRITE = "VERIFYSOURCEOLDER"

	IfInt $(WinNTSystemMajorVersion) < 4
		AddSectionFilesToCopyList Files-$(Option)3 $(SrcDir) $(!STF_WINDOWSSYSPATH)
		AddSectionFilesToCopyList Files-Inf3 $(SrcDir) $(!STF_WINDOWSSYSPATH)
	Else
		AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)
		AddSectionFilesToCopyList Files-Inf $(SrcDir) $(!STF_WINDOWSSYSPATH)
	EndIf

	Set !STF_NCPA_FLUSH_COPYLIST = TRUE

	CopyFilesInCopyList

	Exit

;***********************************************************************

[Source Media Descriptions]

	1 = "MicroGate SyncLink Setup Disk #1"

;***********************************************************************

[ProductType]

	STF_PRODUCT  = Winnt
	STF_PLATFORM = I386

;***********************************************************************

[Files-Inf3]

	1, oemsetnt.inf, SIZE=1000, RENAME=$(!UG_Filename)
	1, mgslset.hlp, SIZE=50000
	1, MGSLDIAG.SYS, SIZE=30000, RENAME=Drivers\MGSLDIAG.SYS
	1, mgslset3.dll, SIZE=45000
	1, mgslset.dll, SIZE=45000

;***********************************************************************

[Files-MGSL3]

	1, MGSLDIAG.SYS, SIZE=30000, RENAME=Drivers\MGSLDIAG.SYS
	1, MGSL.SYS, SIZE=40000, RENAME=Drivers\MGSL.SYS
	1, mgslset.hlp, SIZE=50000
	1, mgslset3.dll, SIZE=45000
	1, mgslset.dll, SIZE=45000

;***********************************************************************

[Files-Inf]

	1, oemsetnt.inf, SIZE=1000, RENAME=$(!UG_Filename)
	1, mgslset.hlp, SIZE=50000
	1, mgslset.dll, SIZE=45000
	1, MGSLDIAG.SYS, SIZE=30000, RENAME=Drivers\MGSLDIAG.SYS

;***********************************************************************

[Files-MGSL]

	1, MGSLDIAG.SYS, SIZE=30000, RENAME=Drivers\MGSLDIAG.SYS
	1, MGSL.SYS, SIZE=40000, RENAME=Drivers\MGSL.SYS
	1, mgslset.hlp, SIZE=50000
	1, mgslset.dll, SIZE=45000


;***********************************************************************

[LanguagesSupported]

    ENG

;***********************************************************************

[OptionsTextENG]

    MGSL = "MicroGate SyncLink Internet Adapter"

;***********************************************************************

[FileConstantsENG]

    ProCaption          = "Windows NT Setup"
    ProCancel           = "Cancel"
    ProCancelMsg        = "Windows NT Networking is not correctly installed.  "+
                          "Are you sure you want to cancel copying files?"
    ProCancelCap        = "Network Setup Message"
    ProText1            = "Copying:"
    ProText2            = "To:"

    FunctionTitleMGSL                = "MicroGate SyncLink Internet Adapter Setup"
    ProductSoftwareDescription       = "MicroGate SyncLink Internet Adapter Driver"
    ProductHardwareMGSLDescription   = "MicroGate SyncLink Internet Adapter"
    ProductSoftwareTitle             = "MicroGate SyncLink Internet Adapter Driver"
    ProductHardwareMGSLTitle         = "MicroGate SyncLink Internet Adapter"

    ShellCodeErrorTitle              = "Error: "$(FunctionTitle)$(Option))
    ShellCodeErrorText               = "Shell Code Error."

;***********************************************************************

[DialogConstantsENG]
    Help                = "&Help"
    Exit                = "Cancel"
    OK                  = "OK"
    HelpContext         = ""
    Continue            = "Continue"
    Cancel              = "Cancel"

;***********************************************************************

[FileDependentDlgENG]


;***********************************************************************

[InvokeRasDlgENG]

    InvokeRasSetupMsg   = "MicroGate SyncLink Internet Adapter setup is complete. "+
                          "Remote Access Services (RAS) must now be installed. "+
                          "Please configure the MGSL ports in RAS "+
                          "setup to enable you to use RAS over the MGSL."

    InvokeRasConfigMsg  = "MicroGate SyncLink Internet Adapter setup is complete. "+
                          "Remote Access Services (RAS) setup must now be invoked. "+
                          "Please configure the MGSL ports in RAS "+
                          "setup to enable you to use RAS over the MGSL."

    InvokeRasError      = "MicroGate SyncLink Internet Adapter setup encountered an error "+
                          "while invoking the RAS setup INF file (OEMNSVRA.INF). "+
                          "Please make sure that the file is present in the "+
                          "System32 directory and is the proper file." 


;****************************************************************************

[SetAdapterDefaults]

	Set BaseAddr = 768
	Set IrqLevel = 9
	Set DmaLevel = 1
	Set ConnectType = 0
	Set ConnectIndicator = 0
	Set Encoding = 0
	Set ConstantRTS = 1
	Set InitString = "AT&C1&D2&S1&Q1S0=0^M"
	Set LinkSpeed = 9600
	Set ExternalClockingSpeed = 0

	return 	$(BaseAddr) +
		$(IrqLevel) +
		$(DmaLevel) +
		$(ConnectType) +
		$(ConnectIndicator) +
		$(Encoding) +
		$(ConstantRTS) +
		$(InitString) +
		$(ExternalClockingSpeed) +
		$(LinkSpeed) 

;***********************************************************************

[MgGetSysVersion]

	OpenRegKey $(!REG_H_LOCAL) "" + 
		"SOFTWARE\Microsoft\Windows NT\CurrentVersion" +
		$(!REG_KEY_ALL_ACCESS) KeyVersion

	IfStr(i) $(KeyVersion) != ""
		GetRegValue $(KeyVersion) "CurrentVersion" CurrentVersion
		CloseRegKey $(KeyVersion)
		Split-String *($(CurrentVersion),4) "." VersionComponents
	Else
		Shell $(!STF_WINDOWSSYSPATH)"\SUBROUTN.INF" SetupMessage $(!STF_LANGUAGE) WARNING +
			"Error Cant open registry key!"
	EndIf

	return 	*($(VersionComponents),1)



