' **************************************************
' * Script generated by Virtual CD v5
' * Copyright 2003 by H+H Software GmbH
' **************************************************
Option Explicit

Const VCD_ERROR_NONE = 0
Const DLGTITLE = "Virtual CD Script"
Const DLGERRORMSG = "Error while inserting a virtual CD "
Const DLGEC = " EC: "

DIM IApi			' Virtual CD v4 SDK API Object

' Init the VCD SDK object
Set IApi = CreateObject("Vc5api.Api")

' Insert the virtual CDs
#VCDINSERTBLOCK

Set IApi = Nothing
WScript.Quit(0)

' **************************************************
' Insert a virtual CD
' strVCDDrive - Drive letter (empty for default)
' strVCDName - Name of the virtual CD
' **************************************************
Function InsertVCD(strVCDDrive, strVCDName)
	DIM strDrive		' current drive of a VCD
	DIM strVCDDrives	' Available virtual dirves

	' If there is no file name stop
	If Len(strVCDName) <> 0 Then
		' get the virtual drive where the CD is inserted
		strDrive = IApi.VCDGetMountDrive(strVCDName)
		
		' eject the CD if it was inserted
		If Len(strDrive) <> 0 then
			IApi.VCDEject(strDrive)
		End If
	
		' insert the virtual CD
		InsertVCD = IApi.VCDInsert(strVCDDrive, strVCDName, "")
		
		' if something was wrong come up with an error
		If InsertVCD <> VCD_ERROR_NONE then
			MsgBox DLGERRORMSG & strVCDName & DLGEC & InsertVCD, vbExclamation, DLGTITLE
		End If
	End If
End Function
