Thanx for your reply oliver.
I realised this later on yesterday evening and I've now changed it to:
CString* strPathname = new CString(listOfFiles.GetNext(pos)); // pathname + filename
CString* strFilename = new CString(strPathname->Right(strPathname->GetLength() - strPathname->ReverseFind('\\')-1)); // just the filename
2) The following line will appear funny to you once you think about it once again:
I spotted that also and changed the code, after creating my NeroCreateIsoItem() for all elements :
for (int nElement = 0; nElement < nCount; nElement++)
m_niiFile[nElement].nextItem = &m_niiFile[nElement+1];
The above code works as is intended as I've viewed the data in debug mode.
4) BUT if you reread the documentation of CString::GetBuffer(), you'll see that this approach is most likely not working at all:
So it all comes down to this: On every iteration of and when the program leaves the "while (pos != NULL)" loop, your "CString strPathname" and "CString strFilename" will be destroyed. With them, the requested buffer will also be destroyed. The result is that the created NERO_ISO_ITEMs are pointing to garbage memory.
I just wonder why you didn't get an access violation or similar on NeroCreateIsoTrackEx...
See code in point 1).
5) One more thing: Did I saw the dereferencing operator in this line?
m_niiFile[nCount] = *NeroCreateIsoItem();
Assignment of the NERO_ISO_ITEM structure can not be done this way. Your array should really hold pointers to the created NERO_ISO_ITEMs. You will also be unable to destroy the ISO tree if you just assign the object instead of the object pointer. And by the way: Where do you and how will you ever call NeroFreeIsoItem or NeroFreeIsoItemTree anyway? You do not store the pointers to the created items, so you got memory leaks which will be reported by the Nero SDK when you call NeroDone().
Your point is correct, in that I'm exepriencing memory leaks from the NERO API and has got me stumped because if I do the following :
m_niiFile = new NERO_ISO_ITEM[listOfFiles.GetCount()];
if I create m_niiFile as an array instead of creating it dynamically then the following works, but as I'm creating it dynamically....
m_niiFile[nCount] = NeroCreateIsoItem(); // compiler error
m_niiFile[nCount] = *NeroCreateIsoItem(); // causes memory leaks
I have got the Burning application to work in that it copies the intended files but, as you quite rightly pointed out, I'm getting memory leaks from, I guess, NeroCreateIsoItem().
Any further ideas? I've viewed your code :
Nero API Example, but your example only creates NERO_ISO_ITEM's on the stack, and not the heap. Does the Nero API ensure that NERO_ISO_ITEM can only be created on the stack?