Reputation: 375
I have read hackchina and codeproject examples but it seems I can not figure out how to burn an existing .iso file. The examples above show ways of making an .iso from a folder and then burning it. I want to be able to directly burn an iso file.
Here is some code:
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;
......
......
Could someone please help me get further? Lets say I have example.iso. What should I do now? I don't understand. (I got using IMAPI2.interop in my code from CodeProject example).
Thanks a lot
Upvotes: 2
Views: 2034
Reputation: 375
Well i finally figured it out firstly you need to include the following name spaces:
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
In order to be able to use IStream.
Then you need to import SHCreateStreamOnFIle from shlwapi.dll to open a "read stream" to that 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);
and finally supply i to the discFormatData.Write() method.
discFormatData.Write(stream);
I hope it helps someone. Take care
Upvotes: 3