C++
[C#](Creating Audio CDs using IMAPI2 - CodeProject)
imapi2
Imapi2可以在Windows7上稳定运行,但是在Windows10上运行在续刻的时候总会出现错误,原因暂时还未查明
提供可覆写功能
// 增加文件内容,可覆盖刻录
public bool AddToOverrideFileSystem(IFsiDirectoryItem rootItem, MsftFileSystemImage fileSystem, string path)
{
IStream stream = null;
path += $"\\{displayName}";
try
{
Win32.SHCreateStreamOnFile(filePath, Win32.STGM_READ | Win32.STGM_SHARE_DENY_WRITE, ref stream);
rootItem.AddFile(path, stream);
return true;
}
catch(Exception ex)
{
Console.WriteLine($"增添文件失败.{ex.Message}");
}
finally
{
if (stream != null)
{
Marshal.FinalReleaseComObject(stream);
}
}
return false;
}
// DirectoryItem
// 递归增加文件夹与文件
public bool AddToOverrideFileSystem(IFsiDirectoryItem rootItem, MsftFileSystemImage fileSystem,string path)
{
path += $"\\{displayName}";
if (fileSystem.Exists(path) == FsiItemType.FsiItemNotFound)
{
rootItem.AddDirectory(path);
}
foreach (var item in mediaItems)
{
item.AddToOverrideFileSystem(rootItem, fileSystem, path);
}
return true;
}