Burning Multisession CDs with IMAPI2 in WSH - Getting started
(Page 2 of 5 )
The process for burning multisession discs with IMAPI2 is virtually identical to that of burning single session discs. We'll first set up the recording device, then prepare a data image, and finally, write that image to disc. The process differs in how we create the disc image.
intIndex = 0
strPath = "C:BurnTemp"
Set objDiscMaster = WScript.CreateObject("IMAPI2.MsftDiscMaster2")
Just as before, we'll begin by telling our script to set a few variables. We'll provide the index number of the drive we wish to use to burn our CD along with a path to the files that should be added.
We'll also create a reference to the IMAPI DiscMaster object. This object returns a collection of all the optical devices on the system.
Set objRecorder = WScript.CreateObject("IMAPI2.MsftDiscRecorder2")
strDevice = objDiscMaster.Item(Index)
objRecorder.InitializeDiscRecorder(strDevice)
Next, we'll create a reference to the device we'll be using to record our CD. The MsftDiscRecorder2 namespace returns an object that represents a recording device. We'll then get a string that contains a unique ID for the device we wish to use. Finally, we'll use the InitializeDiscRecorder method to bind the recorder object to the actual device on the system.
Set objImageWriter = CreateObject("IMAPI2.MsftDiscFormat2Data")
objImageWriter.Recorder = objRecorder
objImageWriter.ClientName = "Multisession CD"
Once a reference exists to a burning device, an ImageWriter object can be created to actually do the work. The Recorder property is used to indicate what recording device to use, and the ClientName property is used to provide a friendly name. This is the object that will be used to create an image of the current session and provide that to the recorder for writing.
Set objFSI = CreateObject("IMAPI2FS.MsftFileSystemImage")
At this point, set up of the disc and current recording session is complete. It's now time to begin creating an image of the current burn session.
Next: Building the burn image >>
More Windows Scripting Articles
More By Nilpo