Introduction to IMAPI
In recent past, I have seen few question coming to me asking, “How do I write data on the CD/DVD disk programmatically?” . During my research, I have good introduction to the interfaces available on Windows for burning CD/DVD programmatically that I want to share with all.
There are two basic way to burn CD/DVD. One question can come pretty early, How does Windows OS in-built functionality works? On Windows XP onwards ( could not check on Windows 2000 or earlier, probably there is none ) we can burn the disc by dragging the files/folders on to the disc. OS does it with the shell interface ICDBurn Interface. If you want to burn the files/folders in your program you can use ICDBurn interface but before calling ICDBurn::Burn Method, you need to copy the files/folders in a specific location called CD Staging Area. Once your application selects the files/folders to be written in the CD/DVD and copied to the CD Staging area, calling ICDBurn::Burn Method will burn the CD/DVD, same as OS and delete the files from that location automatically. CD Staging area can be determined by the application by the information available in MSDN documentation as below --
The staging area has a default location of %userprofile%\Local Settings\Application Data\Microsoft\CD Burning. Its actual path can be retrieved through SHGetFolderPath, SHGetSpecialFolderPath, SHGetFolderLocation, SHGetSpecialFolderLocation, or SHGetFolderPathAndSubDir by using the CSIDL_CDBURN_AREA value.
Other way to burn CD/DVD is using Image Mastering API or IMAPI in short. IMAPI comes in two versions IMAPIv1 and IMAPIv2. IMAPIv1 is available for application to be used on Windows XP and Windows Server 2003 and IMAPIv2 is available on Windows Vista onwards, in-box. You can also get the IMAPIv2 available on Windows XP and Windows Server 2003 after installing a package, links and information are below--
IMAPI 2.0 is included in Windows Vista. Enabling the same functionality for Windows XP and Windows Server 2003 requires the installation of the KB932716 update package.
After installing Description of the Image Mastering API v2.0 (IMAPIv2.0) update package that is dated June 26, 2007 on Windows XP or Windows Server 2003, application can use the interfaces exposed by IMAPIv2.
Note – Before burning any CD/DVD please see through documentation that which filesystem you want the IMAPI interfaces to be written on the disc? There are few options available like ISO9660, Joliet and UDF.
Next, few links to be shared for IMAPIv1 interfaces available.
IDiscMaster::RecordDisc Method
Next, few links to be shared for IMAPIv1 interfaces available.
Also, IMAPIv2 has multisession support and interfaces are available.
Samples- While there are code snippet sample available on MSDN documentations of the interface/method, there are 2 complete sample applications available in Windows SDK for Vista ( onwards ). Sample locations are below after you install Windows SDK on the dev machine ---
%program files%\Microsoft SDKs\Windows\v6.0\Samples\WinBase\imapi\imapi2sample
%program files%\Microsoft SDKs\Windows\v6.0\Samples\WinBase\storage\IBurn
While imapi2sample is native code in C++, IBurn sample is managed in C#. Please refer to the samples for more understandings of the IMAPI, that can give good start if you want to develop a feature/application for CD/DVD burning.
Nitin Dhawan
Windows SDK – Microsoft