I have just started working with the StarBurn SDK. I am trying to create a simple windows console app that just runs through all the functions to burn a directory to a cd.
Everything goes fine until I call StarBurn_ISO9660JolietFileTree_Add which gives me an access voilation. (Unhandled exception at 0x027e5a49 in StarBurnTest.exe: 0xC0000005: Access violation writing location 0x00000001.) I have tried it both in Visual C++ 6 and Visual Studio .NET.
The callback for FileTree_Add gets called once and runs through with no problems.
Here is my sample code:
EXCEPTION_NUMBER en = EN_SUCCESS;
long lDeviceCount = 0;
long lWriterCount = 0;
STARBURN_DEVICE_INFO* pWriterInfo = NULL;
void* pCDGrabber = NULL;
void* pFileTree = NULL;
void* pTreeRoot = NULL;
char szException[1024] = {0};
unsigned long ulSysError = 0;
CDB_FAILURE_INFORMATION cdbFailInfo = {0};
char szNewRoot[MAX_PATH] = {0};
g_pDevices = new fdList();
en = StarBurn_UpStartEx(g_StarBurn_Reg_Key,sizeof(g_StarBurn_Reg_Key));
SB_EXIT_FAIL(en);
lDeviceCount = StarBurn_FindDevice(SCSI_DEVICE_RO_DIRECT_ACCESS,FALSE,(PCALLBACK)SBFindDeviceCB,(void*) &lWriterCount);
SB_EXIT_FAIL(en);
fdNode* pNode = g_pDevices->Head();
OutputDebugString("Writers Found:\n");
while(pNode){
pWriterInfo = (STARBURN_DEVICE_INFO*) pNode->Data();
OutputDebugString(pWriterInfo->VendorID);
OutputDebugString(pWriterInfo->ProductID);
OutputDebugString("\n");
pNode = pNode->GetNext();
}
if(pWriterInfo){
// create burnergrabber object
en = StarBurn_CdvdBurnerGrabber_Create(&pCDGrabber,szException,sizeof(szException),&ulSysError,&cdbFailInfo,
(PCALLBACK) SBBurningCB,NULL,pWriterInfo->PortID,pWriterInfo->BusID,
pWriterInfo->TargetID, pWriterInfo->LUN,0);
// test for disk
while(StarBurn_CdvdBurnerGrabber_GetInsertedDiscType(pCDGrabber) == DISC_TYPE_NO_MEDIA){
if(MessageBox(::GetDesktopWindow(),"Please insert Media","NO Disc",MB_OKCANCEL | MB_ICONHAND) == IDCANCEL)
break;
}
// create the file tree
en = StarBurn_ISO9660JolietFileTree_Create(&pFileTree,szException,sizeof(szException),&ulSysError,
(PCALLBACK) SBBurningCB,&g_TreeNodes,TRUE,FALSE,TRUE,FILE_TREE_JOLIET);
SB_EXIT_FAIL(en);
// get the root
pTreeRoot = StarBurn_ISO9660JolietFileTree_GetRoot(pFileTree);
ZeroMemory(szNewRoot,sizeof(szNewRoot));
time_t t = time(0);
sprintf(szNewRoot,"%s",ctime(&t));
for(int i = 0; i < strlen(szNewRoot); i++){
if( (szNewRoot[i] == ':') || (szNewRoot[i] == ' ')){
szNewRoot[i] = '_';
}
if(szNewRoot[i] == '\r\n'){
szNewRoot[i] = 0;
break;
}
}
// add a file
en = StarBurn_ISO9660JolietFileTree_Add(pFileTree,szException,sizeof(szException),&ulSysError,
g_CopyDir,szNewRoot,FILE_TIME_LAST_WRITE,&pTreeRoot);
SB_EXIT_FAIL(en);
|