我看了Nero 的sample后一次刻录一个文件是成功的,自己通过改编想一次
刻录多个文件就出问题了。不知如何是好,请各位刻录大侠救命啊,等着交差阿
OnBurn()的代码如下
if(saFileName.GetSize()<=0){
 AppendString("You have to choose  files before you can start burning!");
}
else
{
   int iFileNum;
   iFileNum=saFileName.GetSize();
   int size=iFileNum*sizeof(NERO_ISO_ITEM);
   mniiFiles=(NERO_ISO_ITEM*)malloc(size);
   memset(mniiFiles,0,size);
   for(int i=0;i<iFileNum-1;i++){
      
    strcpy(mniiFiles[i].fileName, saFileName.GetAt(i)); 
    strcpy(mniiFiles[i].sourceFilePath, saFilePath.GetAt(i));
    mniiFiles[i].isDirectory=FALSE;
    mniiFiles[i].isReference=FALSE;    // we only have one item    mniiFiles[i].nextItem=NULL;
   }
 // no CD stamp, artist or title required    writeCD.nwcdpCDStamp=NULL;
    writeCD.nwcdArtist=NULL;
    writeCD.nwcdTitle=NULL;    // no CD Extra information available    writeCD.nwcdCDExtra=FALSE;    // we have no Audio tracks    writeCD.nwcdNumTracks=0; // we want to write to a CD
writeCD.nwcdMediaType = MEDIA_CD;    // get the currently selected device from the ComboBox     i = m_cbxDevices.GetCurSel();    // retrieve the NERO_SCSI_DEVICE_INFO pointer for the selected device
    // and assign it to a local variable    NERO_SCSI_DEVICE_INFO* nsdiDevice = (NERO_SCSI_DEVICE_INFO*)m_cbxDevices.GetItemDataPtr(i);    // try to open the selected device    ndhDeviceHandle = NeroOpenDevice(nsdiDevice);    // check whether a valid handle was returned    if (!ndhDeviceHandle)
    {
      // no handle available; tell the user what happened      AppendString("Device could not be opened: "+(CString)nsdiDevice->nsdiDeviceName);
    }
    else
    {
      // we have a valid device handle      // while burning the "Abort" button needs to be enabled
      // all the other buttons and controls have to be disabled      m_btnAbort.EnableWindow(true);
      m_btnCancel.EnableWindow(false);
      m_btnOk.EnableWindow(false);
      m_cbxDevices.EnableWindow(false);
      m_btnBrowse.EnableWindow(false);
      m_btnBurn.EnableWindow(false);      // set the range for the progress control, we will display percent      m_pgsProgress.SetRange(0,100);      // create an ISO track
      // usage : NeroCreateIsoTrack(struct NERO_ISO_ITEM *root, const char *name,
      //                            BOOL useJoliet, BOOL useMode2);
      //
      // root = mniiFile, the NERO_ISO_ITEM we filled before
      // name = neroFiddles
      writeCD.nwcdIsoTrack = NeroCreateIsoTrackEx(mniiFiles, "neroFiddles", NCITEF_CREATE_ISO_FS|NCITEF_USE_JOLIET);      // start the burn process by calling NeroBurn
      // usage:NEROAPI_BURN_ERROR NADLL_ATTR NeroBurn( NERO_DEVICEHANDLE  aDeviceHandle,
      // NERO_CD_FORMAT  CDFormat, const void*  pWriteCD, DWORD  dwFlags, DWORD  dwSpeedInX,
      // NERO_PROGRESS*  pNeroProgress);
      //
      // aDeviceHandle = ndhDeviceHandle, the handle we got from NeroOpenDevice()
      // CDFormat = NERO_ISO_AUDIO_CD
      // pWriteCD = writeCD
      // dwFlags = NBF_WRITE, do not simulate - burn!
      // dwSpeedInX = 0, use maximum speed
      // pNeroProgress = npProgress, filled during NeroAPIInit()      int iRes = NeroBurn(ndhDeviceHandle, NERO_ISO_AUDIO_CD, &writeCD, NBF_WRITE, 0, &npProgress);      // free memory that was allocated for the track      NeroFreeIsoTrack(writeCD.nwcdIsoTrack);      // close the device      NeroCloseDevice(ndhDeviceHandle);      // burning is finished, disable "Abort" activate all other controls       m_btnAbort.EnableWindow(false);
      m_btnCancel.EnableWindow(true);
      m_btnOk.EnableWindow(true);
      m_cbxDevices.EnableWindow(true);
      m_btnBrowse.EnableWindow(true);
      m_btnBurn.EnableWindow(true);      // clear the progress bar      m_pgsProgress.SetPos(0);      // make sure that aborted flag is not set if "Burn" button is pressed again      mbAborted = false;      // retrieve the error log      char* Log = NeroGetErrorLog();      // display the error log contents      AppendString(Log);   // free the log
  NeroFreeMem(Log);
      // tell the user how the burn process was finished      switch(iRes)
      {
        case NEROAPI_BURN_OK:
          AppendString ("BurnCD() : burn successful");
          break;
        case NEROAPI_BURN_UNKNOWN_CD_FORMAT:
          AppendString ("BurnCD() : unknown CD format");
          break;
        case NEROAPI_BURN_INVALID_DRIVE:
          AppendString ("BurnCD() : invalid drive");
          break;
        case NEROAPI_BURN_FAILED:
          AppendString ("BurnCD() : burn failed");
          break;
        case NEROAPI_BURN_FUNCTION_NOT_ALLOWED:
          AppendString ("BurnCD() : function not allowed");
          break;
        case NEROAPI_BURN_DRIVE_NOT_ALLOWED:
          AppendString ("BurnCD() : drive not allowed");
          break;
case NEROAPI_BURN_USER_ABORT:
          AppendString ("BurnCD() : user aborted");
          break;
case NEROAPI_BURN_BAD_MESSAGE_FILE:
          AppendString ("BurnCD() : bad message file");
          break;
        default:
          AppendString ("BurnCD() : unknown error");
  break;
      }
    }
free(mniiFiles);
}