我读过hackchina和codeproject的例子,但是我似乎想不出如何烧录一个现有的.iso文件。上面的例子展示了如何从文件夹中制作.iso,然后将其烧录。我希望能够直接刻录一个iso文件。
下面是一些代码:
IDiscRecorder2 discRecorder = new MsftDiscRecorder2();
string Burner = comboBox1.SelectedItem.ToString();
foreach (DrvProperties prop in drv_props)
{
if (prop.letter.Contains(Burner)) // letter contains the drive's Letter (E:, G: etc.)
{
discRecorder.InitializeDiscRecorder(prop.ID); // ID contains drive's uniqueID
}
}
IDiscFormat2Data discFormatData = new MsftDiscFormat2Data();
discFormatData.Recorder = discRecorder;
IMAPI_MEDIA_PHYSICAL_TYPE mediaType = discFormatData.CurrentPhysicalMediaType;
......
......有没有人能帮我更进一步?假设我有example.iso。我现在该怎么做?我不明白。(我在CodeProject示例中的代码中使用了IMAPI2.interop )。
非常感谢
发布于 2011-12-24 23:40:09
好吧,我最终弄明白了,首先你需要包含以下名称空间:
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;为了能够使用IStream。
然后,您需要从shlwapi.dll导入SHCreateStreamOnFIle以打开到该iso的“读取流”:
private const uint STGM_SHARE_DENY_WRITE = 0x00000020;
private const uint STGM_SHARE_DENY_NONE = 0x00000040;
private const uint STGM_READ = 0x00000000;
private const uint STGM_WRITE = 0x00000001;
private const uint STGM_READWRITE = 0x00000002;
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false, EntryPoint = "SHCreateStreamOnFileW")]
static extern void SHCreateStreamOnFile(string fileName, uint mode, ref IStream stream);
IStream stream = null;
SHCreateStreamOnFile(path2iso, STGM_READ | STGM_SHARE_DENY_WRITE, ref stream);最后将i提供给discFormatData.Write()方法。
discFormatData.Write(stream);我希望它能帮助一些人。保重
https://stackoverflow.com/questions/8533619
复制相似问题