如何刻录一个已经创建的iso

本文关键字:创建 iso 一个 何刻录 | 更新日期: 2023-09-27 18:17:58

我读过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。我现在该怎么办?我不明白。(我得到使用imapi .interop在我的代码从CodeProject的例子)。

Thanks to lot

如何刻录一个已经创建的iso

我终于明白了,首先你需要包含以下名称空间:

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);

我希望它能帮助到别人。照顾