今天在网上看到网友在讨论C#实现刻录功能,就关注了一下,主要有两种途径:1.XP Burn Componet的使用;
2.通过IMAPI 。下面是我搜集的相关资料。
XP Burn Componet介绍(转载自:http://msdn.microsoft.com/en-us/vcsharp/aa336741.aspx)
The XP Burn Component allows your .NET applications to burn files to CDR/W discs on a Window XP or Windows 2003 Server system. This component does not work for systems which have a different OS installed; though it will detect that case and give a reasonable error message. This component talks directly to the system’s IMAPI interfaces and doesn’t use the Windows XP CD burning wizard, so it’s possible to create your own snazzy UI for burning CDs.
Though the component is a UserControl, I wouldn’t recommend that you put it in the toolbox. Instead, simply reference it and use it like you would use any other framework type (the constructor can potentially throw exceptions, so for robust handling you should wrap it in a try…catch). The documentation and source for the component is included in the download.
You can download the component, developer documentation, and source.
IMAPI 介绍
(转载自:http://blogs.msdn.com/dhawan/archive/2009/11/17/introduction-to-imapi.aspx)
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--
What's New
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 Interface
IDiscMaster::Open Method
IDiscMaster::RecordDisc Method
Next, few links to be shared for IMAPIv1 interfaces available.
IDiscMaster2 Interface
IDiscRecorder2 Interface
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
Published Tuesday, November 17, 2009 8:35 PM by Dhawan
转载于:https://www.cnblogs.com/wuhenke/archive/2009/11/19/1606212.html