Problem in using BurnFreestyleCD() for burning data CD

Hi,

I am using NERO 6.3 version. I am using VC++ as the client to communicate with NEROCOM. I was able to burn Audio CD. but I am facing problem for data CD. I am using BurnFreestyleCD () to make a Data CD. Here are the log messages…

Reading Directories
Creating Directories
Checking Discs
Writing to cache
caching of files started
caching of files completed
writing to Disc
Burn progress started @ 4x 600 kb/s
Writing tracks
Writing Lead in and Lead out
Write Error
could not perform End track

I came to know that “Write Error” is posted if there is a media mismatch. but i am able to make a data CD using Nero Application( which is provided when we buy the software). So I feel that there is some other problem…Please see the piece of Code and let me know where I am going wrong…

HRESULT CEngineIntFace::Burn_Data()
{

HRESULT	hr;
INeroFreestyleTrack *IFreeTrack;
INeroFreestyleTracks *IFreeTrks;
INeroFileSystemDescContainer *IFileDescCont;

INeroFiles *Ifls;	
BSTR bstrname=SysAllocString(L"asd");	
long res;
long speed;
CString sDriveName;
long val;

// Getting the Drives....has to be removed later coz we have already have GetDrives()
//	if(SUCCEEDED(hr))
{
	//	BSTR ArtistName;
	BSTR FileName = SysAllocString(OLESTR("E:\\xx.MP3"));
	hr = INero->GetDrives(NERO_MEDIA_CDR,&Idrives);
	Idrives->get_Count(&res);
	
	for(int i=0;i<res-1;i++)
	{
		Idrives->Item(i,&Idrv);
		Idrv->get_DeviceName(&bstrname);
		//
		Idrv->get_AvailableSpeeds(NERO_ACCESSTYPE_READ,NERO_MEDIA_CDRW,&Ispeeds);
		
		Idrv->get_ReadSpeeds(&Ispeeds);
		Ispeeds->get_Count(&val);
		Ispeeds->get_BaseSpeedKBs(&speed);
		
		sDriveName=(CString)bstrname;
		
	}
	
	// For Burning
	
	hr = CoCreateInstance( CLSID_NeroFolder, NULL, CLSCTX_INPROC_SERVER,
		IID_INeroFolder, (void**) &Ifold);
	
	if(!SUCCEEDED(hr))
	{
		return hr;
	}
	
	hr = CoCreateInstance( CLSID_NeroISOTrack, NULL, CLSCTX_INPROC_SERVER,
		IID_INeroISOTrack, (void**) &Itrk);

	hr = CoCreateInstance( CLSID_NeroFreestyleTrack,NULL,CLSCTX_INPROC_SERVER,
		IID_INeroFreestyleTrack, (void**) &IFreeTrack);

	hr = CoCreateInstance( CLSID_NeroFileSystemDescContainer,NULL,CLSCTX_INPROC_SERVER,
		IID_INeroFileSystemDescContainer, (void**) &IFileDescCont);
	
	hr = CoCreateInstance( CLSID_NeroFreestyleTracks,NULL,CLSCTX_INPROC_SERVER,
		IID_INeroFreestyleTracks, (void**) &IFreeTrks);
	
	if(!SUCCEEDED(hr))
	{

// return hr;
}

	hr = CoCreateInstance( CLSID_NeroFile, NULL, CLSCTX_INPROC_SERVER,
		IID_INeroFile, (void**) &Ifile);
	
	
	if(SUCCEEDED(hr))
	{	
		IFileDescCont->put_BurnOptions(NERO_BURN_OPTION_USE_JOLIET);
		IFreeTrack->put_Title(L"DataCD");
		IFreeTrack->put_Artist(L"Ashok");
		IFreeTrack->put_TrackType(NERO_FREESTYLE_TRACK_MODE1);
		IFreeTrks->Add(IFreeTrack);
		IFreeTrack->put_Filename(L"E:\\xx.txt");

		Ifile->put_SourceFilePath(L"E:\\xx.txt");
		Ifile->put_Name(L"xx.txt");

		hr = Itrk->put_Name(L"TestTrack");
		Itrk->put_RootFolder(Ifold);
	
		Ifold->get_Files(&Ifls);
		Ifls->Add(Ifile);
		Ifls->get_Count(&res);
					
		
		pSink = new CSinkNeroDriveEvents();
		
		if ( NULL == pSink )
		{
			return 0 ;
		}
		
		pSink->AdviseSink(Idrv);

		hr = Idrv->BurnFreestyleCD(IFileDescCont,L"Pop Star",L"Title",0,Itrk,IFreeTrks,NULL,NERO_BURN_FLAG_WRITE,8,NERO_MEDIA_CD);
		Sleep(2000);

	//	m_INero->get_ErrorLog(&bstrname);
	//	CString ash = (CString)bstrname;
		
		Ifold->Release();
		Ifile->Release();
		Itrk->Release();	
		
	}
}

	
return S_OK;

}

thanx in advance,
ARaj