如何使用IWriteEngine2

编程入门 行业动态 更新时间:2024-10-21 11:27:44
本文介绍了如何使用IWriteEngine2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有同样的问题,如social.msdn.microsoft/Forums/en-NZ/windowsopticalplatform/thread/0274808e-45c3-4957-9f87-0bce419cdf45

I have the same problem like social.msdn.microsoft/Forums/en-NZ/windowsopticalplatform/thread/0274808e-45c3-4957-9f87-0bce419cdf45

代码喜欢

OnBurn() { CDiscMaster discMaster; if(!discMaster.Initialize()) { AfxMessageBox("初始化Master失败"); return ; } CDiscRecorder *pDiscRecorder = NULL; for(i = 0; i < discMaster.GetTotalDevices(); i++) { pDiscRecorder = new CDiscRecorder; if(!pDiscRecorder->Initialize(discMaster.GetDeviceUniqueID(i))) { delete pDiscRecorder; pDiscRecorder = NULL; continue; } CDiscFormatData discFormat ; if(!discFormat.Initialize(pDiscRecorder,_T("BurnCDTest"))) { delete pDiscRecorder ; pDiscRecorder = NULL; continue; } break; } if(pDiscRecorder == NULL) { AfxMessageBox("没有找到可刻录的光驱"); return ; } if(!pDiscRecorder->AcquireExclusiveAccess(true,_T("BurnCD"))) { AfxMessageBox(_T("无法获取光驱的独占权")); return ; } CFileObject fileObj(_T("F:\\vc60.rar")); IStream *pIStream = NULL; pIStream = fileObj.GetStream(); CWriteEngine writeEngine; writeEngine.Initialize(pDiscRecorder->GetInterfaceEx(),2048); hr = writeEngine.GetInterface()->put_UseStreamingWrite12(VARIANT_FALSE); writeEngine.Burn(pIStream,20); pDiscRecorder->ReleaseExclusiveAccess(); } bool CWriteEngine::Initialize(IDiscRecorder2Ex *pDiscRecorder2Ex,ULONG bytePerSector) { m_hResult = ::CoCreateInstance(__uuidof(MsftWriteEngine2), NULL, CLSCTX_INPROC_SERVER, __uuidof(IWriteEngine2), (void**)&m_pWriteEngine); if(FAILED(m_hResult)) { return false; } m_hResult = m_pWriteEngine->put_Recorder(pDiscRecorder2Ex); if(!SUCCEEDED(m_hResult)) { return false; } ULONG ulMax; m_hResult = pDiscRecorder2Ex->GetMaximumNonPageAlignedTransferSize(&ulMax); if(ulMax < bytePerSector) { bytePerSector = ulMax; } if(bytePerSector < 1) { bytePerSector = 1; } m_hResult = m_pWriteEngine->put_BytesPerSector(bytePerSector); if(!SUCCEEDED(m_hResult)) { return false; } m_hResult = m_pWriteEngine->put_EndingSectorsPerSecond(-1); m_hResult = m_pWriteEngine->put_StartingSectorsPerSecond(-1); m_hResult = m_pWriteEngine->put_UseStreamingWrite12(VARIANT_TRUE); if(FAILED(m_hResult)) { return false; } return true; } bool CWriteEngine::Burn(IStream *pIstream,long NumofBlocks,bool blast) { // IDiscFormat2RawCD CWriteEngineEvent* eventSink = CWriteEngineEvent::CreateEventSink(); if(eventSink == NULL) { m_errorMsg = _T("Unable to create event sink"); return false; } if(!eventSink->ConnectWriteEngine(this)) { m_errorMsg = _T("Unable to connect event sink with interface"); return false; } // if(!blast) { m_hResult = m_pWriteEngine->WriteSection(pIstream,m_lLastEndSector,NumofBlocks); } // else // { // m_hResult = m_pWriteEngine->WriteSection(pIstream,1,1); // } if(!SUCCEEDED(m_hResult)) { if(m_hResult == E_POINTER) { m_errorMsg = _T("Pointer is not valid."); } else if(m_hResult == E_OUTOFMEMORY) { m_errorMsg = _T("Failed to allocate the required memory."); } else if(m_hResult == E_INVALIDARG) { m_errorMsg = _T("One or more arguments are not valid."); } else if(m_hResult == 0xC0AA0002) { m_errorMsg = _T("The request was canceled."); } else { m_errorMsg = _T("Unkonow error."); } return false; } m_lLastEndSector += NumofBlocks; return true; }

刻录DVD + RW(首先刻录)时,WriteSection因E_IMAPI_UNEXPECTED_RESPONSE_FROM_DEVICE失败。 (DVD + R还可以)

WriteSection failed with E_IMAPI_UNEXPECTED_RESPONSE_FROM_DEVICE when burning DVD+RW(which is first to burn). (DVD+R is ok)

但奇怪的是,使用IDiscFormat2Data来刻录dvd + rw是成功的。更奇怪的是,IWriteEngine可以刻录通过IDiscFormat2Data刻录的DVD + rw。

But strangely, it is successful that use IDiscFormat2Data to burn dvd+rw. More strangely, IWriteEngine can burn the dvd+rw which was burned through IDiscFormat2Data .

根据MSDN,我在使用IWriteEngine2时可以实现五个步骤:

According to MSDN, there are five steps that I can implement when using IWriteEngine2:

  • 通过设置媒体的模式页面来准备硬件。
  • 查询硬件以验证介质是否足够大。
  • 初始化写入,例如,通过格式化媒体或设置OPC。
  • 执行实际的WRITE命令。
  • 通过停止格式化或关闭会话或轨道来完成写入。
  • 但在我的代码中,只有第4步得到了照顾。

    But in my code, only step 4 is cared.

    问题是否发生是因为我没有实施第1步和第3步?如果是这样,我该如何实施它们?

    Does the problem happen because I doesnot implement step1 and 3? If so, how can I implement them?

    任何人都可以帮助我吗?

    Can anyone help me?

    推荐答案

    是的,您看到的问题恰恰是由于缺少步骤1和3. IDiscFormat2Data在空白媒体上执行这些步骤,例如下次使用媒体步骤1和3时不需要。

    Yes the problem you see is precisely due to the absence of steps 1 and 3. IDiscFormat2Data performs these steps on blank media, such that the next time you use the media steps 1 and 3 are not required.

    如果你不能使用IDiscFormat2Data(如果可以简化的话),你需要了解详细信息MMC规范。该规范的价格为 www.t10/drafts.htm#MMC_Family 但是,它要么是T10的成员,要么在ANSI商店购买。富士山规格主要针对DVD-R / RW,但可能包含DVD + R / RW所需的,可从 ftp://ftp.avc-pioneer/ 这些是我们在Microsoft用来开发IMAPI代码的两个规范。

    If you can't use IDiscFormat2Data (which if you can would simplify things), you need to learn the details of the MMC specification. That specification is available at www.t10/drafts.htm#MMC_Family However it requires to either be a member of T10 or to purchase it at the ANSI store. Mt Fuji specifications are focused on DVD-R/RW but may include what you need for DVD+R/RW and are downloadable for free from ftp://ftp.avc-pioneer/These are the two specifications we used at Microsoft to develop our IMAPI code.

    再次,如果您使用IDiscFormat2Data从设置媒体的正确写入参数的相当复杂的任务中抽象出来,那么您的生活会更加简单。

    Again, your life would be a lot simpler if you used IDiscFormat2Data to abstract yourself from the fairly complex task of setting the proper write parameters of the media.

    更多推荐

    如何使用IWriteEngine2

    本文发布于:2023-10-09 06:11:07,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1474914.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:如何使用

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!