'=========================================================================================
' Media Controller Installer Script by Tadis
'=========================================================================================
' More information on this wdiget can be found at myweb.tiscali.co.uk/sidat/
'
'
strInput = InputBox("Type the number that corresponds to " & _
	   "the Media Player you will be using:" & vbcrlf & _
	   vbCrLf & "Winamp/QCD = 1 " & _
	   vbCrLf & "iTunes = 2 " & _
	   vbCrLf & "Foobar = 3 " & vbcrlf & vbcrlf & _
	   "e.g. type '1' if you are want to use Winamp or QCD" , "All-in-One Controller")

Select Case strInput 
	Case ""
	
	Case "1"
	SelectPlayer "1"
'	ChangePath

	Case "2"
	SelectPlayer "2"
'	ChangePath

	Case "3"
	SelectPlayer "3"
'	ChangePath

	Case Else
End Select


'=============================================================================
'=============================================================================
'=============================================================================

Function SelectPlayer(Player)
On Error Resume Next

Dim WshShell
Set WshShell = createobject("wscript.shell")
VBSPATH = WshShell.RegRead ("HKCU\Software\Serious Samurize\General\DirPath")
TXTPATH = VBSPATH & "Scripts\Media Controller\Media.vbs"
VBSPATH = VBSPATH & "Scripts\Media Controller\Media.txt"

strInput = Readini (VBSPATH)
ChangePlayer = "CONST PLAYER = " & Player
strOutput = Replace(strInput, "CONST PLAYER = 1", ChangePlayer )
createini TXTPATH , strOutput

End Function

'=============================================================================

'Function ChangePath
'Dim WshShell
'Set WshShell = createobject("wscript.shell")
'
'strLen = Len(WScript.ScriptFullName) - 16
'strPath = Mid(WScript.ScriptFullName, 1 , strLen)
'strPath = "wscript.exe " & chr(34) & strPath & "ChangePaths.vbs" & chr(34)
'Wscript.echo strpath
'WshShell.Run strPath , 0 , TRUE
'
'End Function

'=============================================================================

Function Readini(rFile)
Dim rfso, rInFile, strLen, strPathr
Const ForReading = 1, ForWriting = 2, ForAppending = 8

strPathr = rFile
Set rfso = CreateObject("Scripting.FileSystemObject")
Set rInFile = rfso.OpenTextFile(strPathr, ForReading)
Readini = rInFile.ReadAll
End Function

'=============================================================================

Function Createini(vFile, vText)
Dim fso, InFile, OutFile, strText
Set fso = CreateObject("Scripting.FileSystemObject")
Set OutFile = fso.CreateTextFile(vFile, True)
strText = vText
OutFile.Write(strText)
OutFile.Close
End Function