NeroAPI / Burning isolated files in a directory specific to each session

vbimport

#1

Hi everyone! :slight_smile:

I have different 4 files that are localized on different computers or directories. :confused:
Each time I burn these files (they change), I would like to burn them in a directory on the CD. This directory could represent a session, with the different files in. And I would like to change this director name at each session of course… :slight_smile:

Did you already done this ?
How can I do this ?

Thanks in advance for your help! :bow:


#2

Programming language?
Technology… Nerocom, nerocmd, nerosdk?
There are lots of examples throughout this forum maybe you can have a look and see if you can get started from these?


#3

Hi,

Of course I have already look through the forum…
but I didnt find the answer to my problem
My programming language is C++ (Visual 6), and I use NeroAPI

I think I need to modify my NERO_ISO_TRACK to describe the tree… Is anyone have a short exemple ?

Thanks in advance


#4

You mean to modify your NERO_ISO_ITEM. Yes that’s true.
You can set the name of the burnt directory using ‘longFileName’ or ‘unicodeFileName’. Then attach your files to this NERO_ISO_ITEM directory as sundirectory items. Burn the track using NBF_CLOSE_SESSION flag, so you will be able to burn additional sessions on the same disc.
If you want all previous sessions are visible in the last one, you will have each time you burn new session to import the last session from the disc and to merge it with the new one you intend to burn now.


#5

czykit ,could you teld me how to " import the last session from the disc and to merge it with the new one "?could you please give me and example or tel me use which function? thank you very much


#6

I too had a specific multi session archive job I wanted doing. I put together a simple test program using Visual Basic (NeroCom.dll objects).

I then went to do the ‘real thing’ using Visual C++ 6.0, and found that the SDK api supported by Neroapi.dll was very different. I have succesfully created classes from com objects before using the Class Wizard, so I thought I would do the same with NeroCom.dll. It worked a treat, except there were no events. I then manually extended the autogenerated classes and added the events I needed. I also changed some of the functions so that they pass Class instances and not dispatch pointers.

It all worked a treat, and I now have my multi session archive system in place. The new classes are not complete or fully tested, but I have put them, and a test program at

http://www.thedyers.org.uk/Nero.zip

if anyone wants to test them out, or complete the job. Nerocom is a static library with the classes that wrap the Nercom.dll COM objects. I use it with Nero 6.0. I have not tried it with other releases.

NeroTest is a simple GUI application that adds files one at a time to a disk. My full application adds and deletes files and directories to automatically syncronise selected areas of my disk with the contents of a CDR.


#7

Hi, :slight_smile:

I’ve tried to modify my code to burn in a first time my selected files directly in a directory on the CD. Next step will be to burn with multisession…

Here is my code :


int BurnFiles::BurnCD()
{
	char* vMsg = new char[MSG_LENGTH];
	if(m_APIInitialized){
		// Is there something to burn ??
		if(m_NumFiles > 0){
			int res;

			// Number Max of files = 99
			if (m_NumFiles >= 99){
				sprintf(vMsg,"[PRJ] Error Number of files to burn so important (%i) more than 99!",m_NumFiles);
				SetBurnStatus(vMsg);
			}


			// Create the tree of NERO_ISO_ITEMS 
			// 1- Create the root directory
			NERO_ISO_ITEM* v_RootItem = new NERO_ISO_ITEM();
			v_RootItem->longFileName = "TestMulti";
			v_RootItem->isDirectory = true;
			v_RootItem->nextItem = &m_ItemsToBurn[0];
					
			// 2- Chain the others items.
			for (int i = 0; i < m_NumFiles; i++){
				m_ItemsToBurn[i].nextItem = &m_ItemsToBurn[i+1];
			}
			// Close the chain
			m_ItemsToBurn[i+1].nextItem = NULL;


			// 3- Create the IsoTrack Item.
			m_IsoTrack = NeroCreateIsoTrackEx(v_RootItem,m_CDName,NCITEF_USE_JOLIET|NCITEF_CREATE_ISO_FS|NCITEF_CREATE_UDF_FS);
			if (0 == m_IsoTrack)
			{
				SetBurnStatus("[PRJ]NeroCreateIsoTrackEx is failed.
");
			}
			else
			{
			
				// 4- Create the Write CD Structure.
				int size = sizeof (NERO_WRITE_CD) + (m_NumFiles - 1) * sizeof (NERO_AUDIO_TRACK);
				m_WriteCD = (NERO_WRITE_CD *)malloc (size);

				if(!m_WriteCD){
					SetBurnStatus("[PRJ] Memory Problem.. Can t allocate WriteFile Objetc!");
					return WRITECD_MEMORY_PB;
				}

				memset (m_WriteCD, 0, sizeof (m_WriteCD));
				//memset(m_WriteCD , 0 ,size);

				m_WriteCD->nwcdMediaType = MEDIA_CD;
				m_WriteCD->nwcdNumTracks = 0;m_NumFiles;
				m_WriteCD->nwcdArtist = m_Artist;
				m_WriteCD->nwcdTitle = m_Title;

				// m_IsoTrack contains general information.
				m_WriteCD->nwcdIsoTrack = m_IsoTrack;

				res = NeroBurn (m_NeroDeviceHandle,NERO_ISO_AUDIO_CD ,m_WriteCD,
					NBF_WRITE // Write and simulate are not mutually exclusive, we just use either one or the other here.
					| NBF_CLOSE_SESSION
					| NBF_DISABLE_ABORT 
					| NBF_DETECT_NON_EMPTY_CDRW 
					| NBF_SPEED_IN_KBS
					| (m_bup ? NBF_BUF_UNDERRUN_PROT : 0)
					| (m_verify ? NBF_VERIFY : 0)
					| (m_no_eject ? NBF_DISABLE_EJECT : 0),
					m_BurnSpeed*m_SelectedDeviceInfo->nsdiWriteSpeeds.nsiBaseSpeedKBs,
					m_NeroProgress);
				switch(res)
				{
					// 0
					case NEROAPI_BURN_OK:
						break;
					case NEROAPI_BURN_UNKNOWN_CD_FORMAT:
						SetBurnStatus("[PRJ] BurnCD() : unknown CD format");
						break;
					case NEROAPI_BURN_INVALID_DRIVE:
						SetBurnStatus("[PRJ] BurnCD() : invalid drive");
						break;
					case NEROAPI_BURN_FAILED:
						SetBurnStatus("[PRJ] BurnCD() : burn failed");
						break;
					case NEROAPI_BURN_FUNCTION_NOT_ALLOWED:
						SetBurnStatus("[PRJ] BurnCD() : function not allowed");
						break;
					case NEROAPI_BURN_DRIVE_NOT_ALLOWED:
						SetBurnStatus("[PRJ] BurnCD() : drive not allowed");
						break;
					case NEROAPI_BURN_USER_ABORT:
						SetBurnStatus("[PRJ] BurnCD() : aborted by the user");
						break;
					default:
						SetBurnStatus("[PRJ] BurnCD() : unknown error");
				}
				return res;
				NeroFreeIsoTrack (m_IsoTrack);

			}
		}else{
			sprintf(vMsg,"[PRJ] No File in the burn list. Nothing to burn!");
			SetBurnStatus(vMsg);
			return NO_FILE_TO_BURN_ERROR;
		}

	}else{
		sprintf(vMsg,"[PRJ] API not yet initialized. Impossible to burn!");
		SetBurnStatus(vMsg);
		return API_NOT_INITIALIZED;
	}
}

I get an unHandled exception in NEROAPI.DLL…
I suppose the problem is about the IsoTrack object m_IsoTrack, but I don’t undestand where is my problem…

Please, share your expertise with me :bow:

reminder : Language C++ (Vc6.0), NeroAPI 6.6.0.1


#8

Just a few things that I realized reading your code:

You should use NeroCreateIsoItem instead of new NERO_ISO_ITEM.

Is the expression in the loop (2) correct: “m_ItemsToBurn[i+1]”? Do you really have m_NumFiles+1 items to burn in the collection?

Instead of (4) you can use “NERO_WRITE_CD WriteCD;” or something similar.

What’s this: “m_WriteCD->nwcdNumTracks = 0;m_NumFiles;” (ok, its legal C++, but the “m_NumFiles” may be omitted.)

Note that you have to free aquired resources, either with “delete”, “delete[]”, “free” or any “NeroFree*” function, whichever is appropriate in the special case.


#9

hi,

thanks for your reply.
I’ve done some corrections following your usefull instructions.
But i still have my problem… my app crashes when I call NeroBurn function…
Access Violation (0xc0000005) NEROAPI.dll

here is my code…

[I]int VsnPIBurnResults::VsnBurnCD()
{
char* vMsg = new char[MSG_LENGTH];
if(m_APIInitialized){
// Is there something to burn ??
if(m_NumFiles > 0){
int res = -1;
int i = 0;
// Number Max of files = 99
if (m_NumFiles >= 99){
sprintf(vMsg,"[PRJ] Error Number of files to burn so important (%i) more than 99!",m_NumFiles);
SetBurnStatus(vMsg);
}
// Create the tree of NERO_ISO_ITEMS
// 1- Create the root directory
NERO_ISO_ITEM* v_RootItem = NeroCreateIsoItem();
v_RootItem->longFileName = “TestMulti”;
v_RootItem->isDirectory = true;
v_RootItem->nextItem = m_ItemsToBurn[0];

// 2- Chain the others items.
for (i = 0; i &lt; m_NumFiles-1; i++){
  m_ItemsToBurn[i]-&gt;nextItem = m_ItemsToBurn[i+1];
}
// Close the chain
m_ItemsToBurn[i]-&gt;nextItem = NULL;

// 3- Create the IsoTrack Item.
m_IsoTrack = NeroCreateIsoTrackEx(v_RootItem,m_CDName,NCITEF_USE_JOLIET|NCITEF_CREATE_ISO_FS|NCITEF_CREATE_UDF_FS);
if (0 == m_IsoTrack)
{
  SetBurnStatus("[PRJ]NeroCreateIsoTrackEx is failed.

");
}
else
{

  // 4- Create the Write CD Structure.
  NERO_WRITE_CD WriteCD;
  int size = sizeof (NERO_WRITE_CD) + (m_NumFiles - 1) * sizeof (NERO_AUDIO_TRACK);
  WriteCD.nwcdMediaType = MEDIA_CD;
  WriteCD.nwcdNumTracks = m_Num_Files; 
  WriteCD.nwcdArtist= m_Artist;
  WriteCD.nwcdTitle = m_Title;

  // m_IsoTrack contains general information.
  WriteCD.nwcdIsoTrack = m_IsoTrack;

  res = NeroBurn (m_NeroDeviceHandle,NERO_ISO_AUDIO_CD ,&WriteCD,
				NBF_WRITE 
				| NBF_CLOSE_SESSION
				| NBF_DISABLE_ABORT 
				| NBF_DETECT_NON_EMPTY_CDRW 
				| NBF_SPEED_IN_KBS
				| (m_bup ? NBF_BUF_UNDERRUN_PROT : 0)
				| (m_verify ? NBF_VERIFY : 0)
				| (m_no_eject ? NBF_DISABLE_EJECT : 0),
				m_BurnSpeed*m_SelectedDeviceInfo-&gt;nsdiWriteSpeeds.nsiBaseSpeedKBs,m_NeroProgress);
  switch(res)
  {
  case NEROAPI_BURN_OK:
     break;
  case NEROAPI_BURN_UNKNOWN_CD_FORMAT:
    SetBurnStatus("[PRJ] BurnCD() : unknown CD format");
    break;
  case NEROAPI_BURN_INVALID_DRIVE:
    SetBurnStatus("[PRJ] BurnCD() : invalid drive");
    break;
  case NEROAPI_BURN_FAILED:
     SetBurnStatus("[PRJ] BurnCD() : burn failed");
    break;
  case NEROAPI_BURN_FUNCTION_NOT_ALLOWED:
    SetBurnStatus("[PRJ] BurnCD() : function not allowed");
    break;
  case NEROAPI_BURN_DRIVE_NOT_ALLOWED:
    SetBurnStatus("[PRJ] BurnCD() : drive not allowed");
    break;
  case NEROAPI_BURN_USER_ABORT:
    SetBurnStatus("[PRJ] BurnCD() : aborted by the user");
    break;
  default:
    SetBurnStatus("[PRJ] BurnCD() : unknown error");
  }
  // del the tree of nero_items
  NeroFreeIsoItemTree(v_RootItem);
  // del the nero iso track
  NeroFreeIsoTrack (m_IsoTrack);
  delete vMsg;
  return res;
  }
}else{
  sprintf(vMsg,"[PRJ] No File in the burn list. Nothing to burn!");
  SetBurnStatus(vMsg);
  return NO_FILE_TO_BURN_ERROR;
}

}else{
sprintf(vMsg,"[PRJ] API not yet initialized. Impossible to burn!");
SetBurnStatus(vMsg);
return API_NOT_INITIALIZED;
}
}[/I]

my array m_ItemsToBurn is definied in the following fuction :

bool Burn::AddFileToBurnList(char* aFileToAdd, char* aBurntFileName)
{
// onnly files will be added here… no verif at the moment!.. to do for extensions
char* vMsg = new char[MSG_LENGTH];
if(m_APIInitialized){
m_ItemsToBurn[m_NumFiles] = NeroCreateIsoItem();
if(m_ItemsToBurn[m_NumFiles] == NULL){
sprintf(vMsg,“Impossible to add the file %s…!!!”,aFileToAdd);
SetBurnStatus(vMsg);
return false;
}
sprintf(m_ItemsToBurn[m_NumFiles]->sourceFilePath, “%s”, aFileToAdd);
strcpy(m_ItemsToBurn[m_NumFiles]->fileName, aBurntFileName);
m_ItemsToBurn[m_NumFiles]->isDirectory = FALSE;
m_ItemsToBurn[m_NumFiles]->isReference = FALSE;

m_NumFiles++;
sprintf(vMsg,"Add file %s to burn list (file number %d)",aFileToAdd, m_NumFiles);
SetBurnStatus(vMsg);
return true;
}else{
sprintf(vMsg,"API not yet initialized!");
SetBurnStatus(vMsg);
return false;

}
}

do you see more errors in my code ?
What do i wrong ?

thanks for your help
Fpa2


#10

(2) Did you create each item in the m_ItemsToBurn with the appropriate NeroCreateIsoItem function?

(4) The “int size = sizeof…” calculation is obsolete.

(4) Initialize the structure memory by “memset(&WriteCD, 0, sizeof(WriteCD));”. Maybe this caused the access violation.

(4) “WriteCD.nwcdNumTracks = m_Num_Files;” must be set to 0, since this member is for audio-tracks.

(4) Remove Artist and Title, since you do not want to burn an Audio-CD anyway (set to NULL).

Just for testing, at NeroBurn set the burn speed to 0 (max) and the progress to NULL.


#11

Thanks for your answer Oliver
(2) . Yes, all items USED in the array are correctly initialized with the function NeroCreateIsoItem (the function is AddFileToBurnList and is given at the end of the code) (from 0 to m_NumFiles)

(4) I modified my code like this

[I]
// 4- Create the Write CD Structure.
NERO_WRITE_CD WriteCD;
WriteCD.nwcdMediaType = MEDIA_CD;
WriteCD.nwcdNumTracks = 0;
WriteCD.nwcdArtist= NULL;
WriteCD.nwcdTitle = NULL;
// m_IsoTrack contains general information.
WriteCD.nwcdIsoTrack = m_IsoTrack;

res = NeroBurn (m_NeroDeviceHandle,NERO_ISO_AUDIO_CD , &WriteCD,
NBF_WRITE
| NBF_CLOSE_SESSION
| NBF_DISABLE_ABORT
| NBF_DETECT_NON_EMPTY_CDRW
| NBF_SPEED_IN_KBS
| (m_bup ? NBF_BUF_UNDERRUN_PROT : 0)
| (m_verify ? NBF_VERIFY : 0)
| (m_no_eject ? NBF_DISABLE_EJECT : 0),
0, NULL);
[/I]

the result is the same, i still have Acces violation 0xCOOOOO5 when I call NeroBurn function.

In debug mode, I’ve verified the different objects that seems to be correct (Write CD, v_RootItem…etc)

What is wrong again ? :confused:

Fpa2


#12

As mentioned above, try to zeroize the NERO_WRITE_CD structure before you use it:


NERO_WRITE_CD WriteCD;
memset(&WriteCD, 0, sizeof(WriteCD));
WriteCD.nwcdMediaType = MEDIA_CD;
WriteCD.nwcdNumTracks = 0;
WriteCD.nwcdArtist= NULL;
WriteCD.nwcdTitle = NULL;
WriteCD.nwcdIsoTrack = m_IsoTrack;

Does it still crash?

Ah, and please use correct code tags like this: [ code] and [ /code] (without blanks).


#13

Oliver,

Thank you very much for your time and your help!
It seems to works fine now. I have added the previous sessions too, and it’s ok.
:slight_smile:
Thanks again.
best regards

fpa2


#14

You’re welcome.