' **************************************************
' *
' * VCDAPIGetProperties.vbs
' *
' * Copyright 2002-2003 by H+H Software GmbH
' *
' * Virtual CD v5 API example file.
' * Query all properties ao a virtual CD and show
' * them in a dialog
' *
' **************************************************

Option Explicit

DIM IApi			' Virtual CD v5 API Object
DIM iLen			' string length
DIM iRC				' Error code
DIM strFileName		' virtual CD file name
DIM strText			' output
DIM strTitle		' dialog title

'Property results
DIM strDefaultDrive
DIM strDescription
DIM strProgram
DIM strWorkingDir
DIM strComment
DIM iHotKey
DIM iEjectOnEnd

' Error codes
Const VCD_ERROR_NONE = 0

' Properties
Const VCD_PROPERTY_DEFAULTDRIVE = 1
Const VCD_PROPERTY_DESCRIPTION = 2
Const VCD_PROPERTY_PROGRAM = 3
Const VCD_PROPERTY_WORKINGDIR = 4
Const VCD_PROPERTY_COMMENT = 5
Const VCD_PROPERTY_HOTKEY = 6
Const VCD_PROPERTY_EJECTONEND = 7

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

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

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
	ShowProperties()
End If

Set IApi = Nothing

WScript.Quit(0)

'
' Query all properties for a virtual CD and
' show them in a dialog
Public Sub ShowProperties()
	strDefaultDrive = IApi.VCDGetImagePropertiesString(strFileName, VCD_PROPERTY_DEFAULTDRIVE)
	
	' Get the last error code
	iRC = IApi.VCDGetLastError()
	
	If iRC = VCD_ERROR_NONE Then
		strDescription = IApi.VCDGetImagePropertiesString(strFileName, VCD_PROPERTY_DESCRIPTION)
		strProgram = IApi.VCDGetImagePropertiesString(strFileName, VCD_PROPERTY_PROGRAM)
		strWorkingDir = IApi.VCDGetImagePropertiesString(strFileName, VCD_PROPERTY_WORKINGDIR)
		strComment = IApi.VCDGetImagePropertiesString(strFileName, VCD_PROPERTY_COMMENT)
		iHotKey = IApi.VCDGetImagePropertiesLong(strFileName, VCD_PROPERTY_HOTKEY)
		iEjectOnEnd = IApi.VCDGetImagePropertiesLong(strFileName, VCD_PROPERTY_EJECTONEND)
		
		strText = strFileName & " - Properties" & vbCrLf & vbCrLf
		strText = strText & "Default drive" & vbTab & ": " & strDefaultDrive & vbCrLf
		strText = strText & "Description" & vbTab & ": "& strDescription & vbCrLf
		strText = strText & "Working Directory" & vbTab & ": " & strWorkingDir & vbCrLf
		strText = strText & "HotKey" & vbTab & vbTab & ": " & iHotKey & vbCrLf
		strText = strText & "Eject on end" & vbTab & ": "
		
		If iEjectOnEnd = 1 Then
			strText = strText & "Yes" & vbCrLf
		Else
			strText = strText & "No" & vbCrLf
		End If
		
		strText = strText & "Comment" & vbTab & vbTab & ": " & vbCrLf & strComment
		
		MsgBox strText, vbInformation, strTitle
	Else
		MsgBox strFileName & " seems not to be the name of a virtual CD!", vbExclamation, strTitle
	End If
End Sub

