' **************************************************
' *
' * VCDAPIGetDrives.vbs
' *
' * Copyright 2002-2003 by H+H Software GmbH
' *
' * Virtual CD v5 API example file. 
' * Read the exisiting virtual drives and show
' * them in a dialog box.
' *
' **************************************************

Option Explicit

DIM IApi			' Virtual CD v5 API Object
DIM strVCDDrives	' virtual drives
DIM strDrive		' current drive of a VCD
DIM strFileName		' virtual CD file name
DIM iRC				' return value
DIM strTitle		' Dialog title

Const VCD_ERROR_NONE = 0

strTitle = "Virtual CD API Example (VCDAPIInsert.vbs)"

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

' ask for the file name of a virtual CD
strFileName = InputBox("Type in the file name of a virtual CD. Exp: C:\VCDs\test.vc4", strTitle)

' If there is no file name stop
If Len(strFileName) <> 0 Then
	' get the virtual drive where the CD is inserted
	strDrive = IApi.VCDGetMountDrive(strFileName)

	' Insert the CD if it is not still inserted
	If Len(strDrive) = 0 then
		iRC = IApi.VCDInsert("", strFileName, "")

		If iRC <> VCD_ERROR_NONE then
			MsgBox "Error while inserting a virtual CD " & strFileName & " EC: " & iRC, vbExclamation, strTitle
		End If
	Else
		MsgBox "Virtual CD " & strFileName & " was already inserted into virtual Drive " & strDrive & ":", vbInformation, strTitle
	End If
End If

Set IApi = Nothing

WScript.Quit(0)
