'//////////////////////////////////////////////////////////////////////////////
'                                                                            
'  IIIIIII    A                                                            
'    II      A A                        InstallAide (R)                  
'    II     A   A      (c) 2000-2005, InstallAide Software 
'    II     AAAAA      Amethyst   
'  IIIIIII AA   AA                        
'                                                                                                                                                  '
'//////////////////////////////////////////////////////////////////////////////
Dim		BACKSTEP
Dim		NEXTSTEP
Dim		EXITSTEP
Dim 	strStep
Dim 	IAParam
Dim		strTemp
Dim 	strSetupImage
Dim 	strSupportDir
Dim		nState
Dim		strTargetDir

BACKSTEP 	= 1
NEXTSTEP 	= 2
EXITSTEP 	= 3

MS_MODIFY	= 1
MS_RESTORE 	= 2
MS_REMOVE	= 3

Set IAParam 	= Install.CreateIAParam()

If Install.IsInstalled() Then
	OnModify
Else
	OnInstall
End If	

Set IAParam = Nothing

'--------------------------------------------
' 修改安装
'--------------------------------------------
Sub OnModify()
	strStep 		= "SdCopyFile"
	Do While strStep <> "Exit"
		Select Case strStep
				
			Case "SdCopyFile"  
	   			nState = Install.SdCopyFile( IAParam )
				If nState = BACKSTEP Then
					strStep = "SdFinish"
				Else 
					strStep = "SdFinish"
				End If
	   		  
	   		Case "SdFinish"  
	   			Install.SdFinish( IAParam )
				strStep = "Exit"
				
	  		Case Else
	  		   	strStep = "Exit"
		End Select
	Loop	
End Sub

'--------------------------------------------
' 安装系统
'--------------------------------------------
Sub OnInstall()
	strStep 		= "SdWelCom"

	Do While strStep <> "Exit"
		Select Case strStep
		
				
			Case "SdWelCom"
				nState = Install.SdWelcome(IAParam)
				If nState = BACKSTEP Then
					strStep = "SdWelCom"
				ElseIf nState = NEXTSTEP Then
					strStep = "SdLicense"
				Else 
					strStep = "Exit"
				End If
						
	   		Case "SdLicense"  
	   			nState = Install.SdLicense(IAParam)
				If nState = BACKSTEP Then
					strStep = "SdWelCom"
				ElseIf nState = NEXTSTEP Then
					strStep = "SdSetDestPath"
				Else 
					strStep = "Exit"
				End If
	   			
	   		Case "SdSetDestPath"
	   			nState = Install.SdSetDestPath(IAParam)
				If nState = BACKSTEP Then
					strStep = "SdLicense"
				ElseIf nState= NEXTSTEP Then
					strStep = "SdCopyFile"
				Else 
					strStep = "Exit"
				End If
				
			Case "SdCopyFile"  
	   			nState = Install.SdCopyFile( IAParam )
				If nState = BACKSTEP Then
					strStep = "SdSetDestPath"
				ElseIf nState= NEXTSTEP Then
					strStep = "SetVirtualDir"
				Else 
					strStep = "SdFinish"
				End If
	   		  
	   		Case "SetVirtualDir"  
	   			IAParam.SetPrompt "Creating WirtualDir ..."
	   			IAParam.SetAttrib "ShowDialog" , "TRUE"
	   			Install.SdWaiting IAParam
	   			
	   			strTargetDir = Install.GetPath( "PATH_S_TARGETDIR" )
	   			nState = CommObj.CreateVirtualDir( "MyVirtualDir" , strTargetDir )
	   			If nState = 0 Then
	   				msgbox "Create Is Error"
	   			End If
	   			
	   			IAParam.SetAttrib "ShowDialog" , "FALSE"
	   			Install.SdWaiting IAParam
				strStep = "SdFinish"
				
	   		Case "SdFinish"  
	   			Install.SdFinish(IAParam)
				strStep = "Exit"
				
	  		Case Else
	  		   	strStep = "Exit"
		End Select
	Loop
End Sub	