C#實現燒錄功能

來源:互聯網
上載者:User

 今天在網上看到網友在討論C#實現燒錄功能,就關注了一下,主要有兩種途徑:1.XP Burn Componet的使用;

2.通過IMAPI 。下面是我搜集的相關資料。

 XP Burn Componet介紹(轉載自:http://msdn.microsoft.com/en-us/vcsharp/aa336741.aspx)

XP Burn Component

 

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

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.