Nero SDK 1.05, Nero 5.5.10.53 and 6.6.x.x

vbimport

#1

Hi all,

I have implemented a VCD burning program using NeroAPI 1.03 to 1.05. The code is working fine in latest Nero 6.6.x.x. However, one of the requirement is to support older version of nero from 5.5 above. I uninstalled Nero 6.6 and reinstall a Nero 5.5 and my program start throwing “Access violation” error

I have tested the NeroFiddles (from NeroAPI 1.05) with both Nero version and it works fine. Hence, I believe there must be something wrong with my code.

Can somebody help ? The following are part of my code

:
:
:
// get the currently selected device from the ComboBox
int i = mcbxDevices.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*)mcbxDevices.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

  mbtnAbort.EnableWindow(true);
  mCancel.EnableWindow(false);
  mOK.EnableWindow(false);
  mcbxDevices.EnableWindow(false);
  mbtnBrowse.EnableWindow(false);
  mbtnBurn.EnableWindow(false);
  m_PlayBack.EnableWindow(false);
  
  
  m_stcTrans3.ShowWindow(true);
  m_stcTrans3.SetWindowText("Burning in progress");
  // set the range for the progress control, we will display percent
  mpgsProgress.ShowWindow(true)	;
  mpgsProgress.SetRange(0,100);


  //////////////////////////////////////////////////////////////////
  //	Added code for VCD
  //

	BOOL real = TRUE;
	
	BOOL speedtest = FALSE;
	BOOL no_eject = FALSE;

	int num_files = 0;
	int nVCDItemCount = 0;
	struct _finddata_t c_file;
	long hFile;
	
	CString mstrPath;
	CString mstrFPath;
	
	mstrFPath = mstrSysTempPathName;
	mstrPath = mstrSysTempPathName + CString("*.*");
		
	
	if( (hFile = _findfirst(mstrPath , &c_file )) == -1L )
	{   
	   AppendString("No files in current directory!...");	
	}
	else
	{	
	   while( _findnext( hFile, &c_file ) == 0 )
		{	
			if (stricmp (c_file.name, ".."))    
			{	num_files++; 	

				LPCSTR psExt = strrchr (c_file.name, '.');
				if (psExt && (!stricmp (psExt, ".mpg") || !stricmp (psExt, ".mpeg")))
				{ 	nVCDItemCount++; }			
				else if (psExt && (!stricmp (psExt, ".jpg") || !stricmp (psExt, ".jpeg")))
				{ 	nVCDItemCount++; }
				
			}
		}
			
		_findclose( hFile );
	}	
	

	CString *arr;
	arr = new CString[num_files];


	int j=0;
	mstrPath = mstrSysTempPathName + CString("*.mpg");
	if( (hFile = _findfirst(mstrPath , &c_file )) == -1L )
	{   //printf( "No *.c files in current directory!

" );
AppendString(“No *.mpg files in current directory!..”);
}
else
{ arr[j] = c_file.name;j++;
while( _findnext( hFile, &c_file ) == 0 )
{
if (stricmp (c_file.name, “…”))
{ arr[j] = c_file.name;j++; }
}
_findclose( hFile );
}

	mstrPath = mstrSysTempPathName + CString("*.jpg");
	if( (hFile = _findfirst(mstrPath , &c_file )) == -1L )
	{   //printf( "No *.c files in current directory!

" );
AppendString(“No *.jpg files in current directory!..”);
}
else
{ arr[j] = c_file.name;j++;
while( _findnext( hFile, &c_file ) == 0 )
{
if (stricmp (c_file.name, “…”))
{ arr[j] = c_file.name; j++; }
}
_findclose( hFile );
}

	mstrPath = mstrSysTempPathName + CString("*.asf");
	if( (hFile = _findfirst(mstrPath , &c_file )) == -1L )
	{   //printf( "No *.c files in current directory!

" );
AppendString(“No *.asf files in current directory!..”);
}
else
{ arr[j] = c_file.name;j++;
while( _findnext( hFile, &c_file ) == 0 )
{
if (stricmp (c_file.name, “…”))
{ arr[j] = c_file.name;j++; }
}
_findclose( hFile );
}

	NERO_WRITE_VIDEO_CD * pWriteCD;
	int size = sizeof (NERO_WRITE_VIDEO_CD) + (nVCDItemCount - 1) * sizeof (NERO_VIDEO_ITEM);
	
	pWriteCD = (NERO_WRITE_VIDEO_CD *) new char[size];
	if (!pWriteCD) {
		AppendString ("BurnCD() : No memory");
		delete pWriteCD;
		return;
	}

	memset (pWriteCD, 0, size);
	

	pWriteCD->nwvcdSVCD = 0;
	pWriteCD->nwvcdNumItems = nVCDItemCount;

	//////////////////////////////////////////////////////////////
	//	Copying the Source files 
	//
	//
	
	NERO_ISO_ITEM* ppItem = NULL;
	

	NERO_ISO_ITEM * pNewItem = NeroCreateIsoItem ();
	if (NULL == pNewItem)
	{
		//DeleteIsoItemTree (*ppItem);
		return ; //EXITCODE_OUT_OF_MEMORY;
	}

	// Attach this item to the beginning of the list.

	if (ppItem != NULL)
	{
		pNewItem->nextItem = ppItem;
	}
	ppItem = pNewItem;

	//NERO_ISO_ITEM * pNewItem = NeroCreateIsoItem ();
	pNewItem->isDirectory = TRUE;
	strcpy (pNewItem->fileName, "FILES");
	
	//time_t t ; //= ff.GetCreateTime ();
	//pNewItem->entryTime = *localtime (&t);

	int nVCDItemsAdded = 0;
	for (i=0;i<num_files;i++)
	{

		int iNameSize = sizeof (pWriteCD->nwvcdItems[nVCDItemsAdded].nviSourceFileName);
		mstrPathName = mstrFPath + arr[i];
		LPCSTR sFileName = mstrPathName;
		
		
		// MPEG and JPEG are allowed types
		// stricmp performs a lowercase comparison and returns 0 if the strings are identical.
		// We fill in type information and file name.

		LPCSTR psExt = strrchr (sFileName, '.');

		if (psExt && (!stricmp (psExt, ".mpg") || !stricmp (psExt, ".mpeg")))
		{
			NERO_VIDEO_ITEM* item = &pWriteCD->nwvcdItems[nVCDItemsAdded];
			strncpy (item->nviSourceFileName, sFileName, iNameSize);
			item->nviSourceFileName[iNameSize - 1] = 0;
			item->nviItemType = NERO_MPEG_ITEM;
			nVCDItemsAdded++;
			// no pause after mpeg items

			item->nviPauseAfterItem=0;
			//AddSourceFiles(&pNewItem->subDirFirstItem,arr[i],mstrPathName);	
		}
		else if (psExt && (!stricmp (psExt, ".avi") || !stricmp (psExt, ".asf") ))
		{
			//item->nviItemType = NERO_NONENCODED_VIDEO_ITEM;
			
			// no pause after avi items

			//item->nviPauseAfterItem=0;

			AddSourceFiles(&pNewItem->subDirFirstItem,arr[i],mstrPathName);					

		}
		else if (psExt && (!stricmp (psExt, ".jpg") || !stricmp (psExt, ".jpeg")))
		{
			NERO_VIDEO_ITEM* item = &pWriteCD->nwvcdItems[nVCDItemsAdded];
			strncpy (item->nviSourceFileName, sFileName, iNameSize);
			item->nviSourceFileName[iNameSize - 1] = 0;			
			item->nviItemType = NERO_JPEG_ITEM;

			// infinite pause after jpeg items
			//item->nviPauseAfterItem=-1;
			item->nviPauseAfterItem=450;
			nVCDItemsAdded++;
			AddSourceFiles(&pNewItem->subDirFirstItem,arr[i],mstrPathName);	
		}

	}
  	
	NERO_CITE_ARGS citeArgs;

	memset (&citeArgs, 0, sizeof (citeArgs));

	citeArgs.dwBurnOptions = NCITEF_USE_MODE2|NCITEF_USE_JOLIET;
	citeArgs.name = "VCD";
	citeArgs.firstRootItem = ppItem;
  pWriteCD->nwvcdIsoTrack = NeroCreateIsoTrackEx(NULL, (const char *) &citeArgs, NCITEF_USE_STRUCT);
	
  AppendString("Preparing to Burn VCD");
  int iRes=0;
  //Set burning flag
  mdwBurnFlag = NBF_WRITE|NBF_CLOSE_SESSION|NBF_DISABLE_EJECT;

  //Enable buffer underrun protection
  if (nsdiDevice->nsdiCapabilities & NBF_BUF_UNDERRUN_PROT)
  {
	  mdwBurnFlag |= NBF_BUF_UNDERRUN_PROT;
  }
  
  if (nsdiDevice->nsdiCapabilities & NBF_DAO)
     {
	  mdwBurnFlag |= NBF_DAO;
  }

//Error occur once calling NeroBurn with Nero 5.5.10.53 installed
//Works OK with Nero 6.6.x.x

  //Start to burn (1st phase or real burn)
  iRes = NeroBurn (ndhDeviceHandle, NERO_VIDEO_CD ,pWriteCD, mdwBurnFlag, 0, &npProgress); 

:
:

Thanks in advance :bow:


#2

There are some essential problems in your code such as:

if (nsdiDevice->nsdiCapabilities & NBF_BUF_UNDERRUN_PROT)
{
mdwBurnFlag |= NBF_BUF_UNDERRUN_PROT;
}
 
if (nsdiDevice->nsdiCapabilities & NBF_DAO)
{
mdwBurnFlag |= NBF_DAO;
}

NBF_ is a prefix for burn flags, while NSDI_ is the prefix for capabilities flags. These two aren’t really interchangable. Your code might hide some more issues like this one, even though this is not the cause of your problems, but more like a cause of improper behavior.

Try using NeroCreateProgress() to dynamically allocate NERO_PROGRESS structure instead of simply declaring it as a stack variable.


#3

Thanks for pointing out my error.

Unfortunately, I can’t use NeroCreateProgress() since some of my client machine still using Nero 5.5 where NeroCreateProgress() was introduced in Nero 6. Luckly, I have tested my code with Nero 5.5.10.56 and it works without throwing “Access violation” (the error occur when I use Nero 5.5.10.53). Now, I can get my client to update their software. :smiley: