Burning CDs with the IMAPI2 Control - Preparing a Disc Image
(Page 3 of 4 )
Now you’ll need to initialize the burn device and begin preparing a disc image to write. Remember that files cannot be copied directly to a CD. Instead, an image of the new disc's file system must be created first and then written to the disc.
Set objRecorder = WScript.CreateObject("IMAPI2.MsftDiscRecorder2")
strDevice = objDiscMaster.Item(intIndex)
objRecorder.InitializeDiscRecorder(strDevice)
Continuing with the burn script, you’ll need to connect to the IMAPI DiscRecorder object. This is an object that will be used to reference the CD burner that will be used to write the disc. You’ll first need to retrieve the device identifier string from the DiscMaster object. Then, you must attach the device to the Recorder object reference using the InitializeDiscRecorder method.
This is overly complicated. This is just a fancy way of telling the IMAPI control what device we want to use as a burner.
Set objImageWriter = CreateObject("IMAPI2.MsftDiscFormat2Data")
objImageWriter.Recorder = objRecorder
objImageWriter.ClientName = "IMAPI Script"
IMAPI’s MsftDiscFormat2Data interface is used to create an image writer object. You can then specify a recording device using the Recorder property. The ClientName property is used to specify a friendly name for the image writer client.
Set objFSI = CreateObject("IMAPI2FS.MsftFileSystemImage")
objFSI.ChooseImageDefaults(objRecorder)
Now that the recording device has been selected and initialized, it’s time to begin building the actual burn image. The MsftFileSystemImage interface is used to create an image object. Think of this as a kind of empty ISO file.
You must also specify the type of file system to use along with the other settings for the image. This is most easily done by using the ChooseImageDefaults method. This method will examine the provided device and its current media and set the image settings accordingly.
objFSI.FileSystemsToCreate = 1
Rather than using the ChooseImageDefaults method, you may specify a file system for the resulting image if you wish. This can be accomplished using the FileSystemToCreate property. The possible choices are listed in the table below.
FsiFileSystemISO9660 | 1 |
FsiFileSystemJoliet | 2 |
FsiFileSystemUDF | 3 |
Next: Burning the Disc >>
More Windows Scripting Articles
More By Nilpo