// JP opened flex table

Click to See Complete Forum and Search --> : CD Locks after an application that's CD writing crashed


hanksloka
April 25th, 2007, 06:32 AM
Hi,

Situation is as follows:-

Using Nero SDK, during a CD burn, to simualte a crash I end the application process with the task manager.

Reloading the application and trying the burn again locks for 8 minutes then fails.

The CD writer isn't available to any other application either and won't even eject when the physical eject button is pressed.

This looks like it's locked at the windows level and not anything to do with Nero. Does any one know how to recover nicely from this as the only solution so far is to tell the customer to reboot the PC. As this is a video security system, this really isn't a good option!

Thanks in advance.
Hank

Krishnaa
April 25th, 2007, 07:22 AM
Yes, this happens because of handle remains in use, try using Unhandled Exceltpion Filter (http://msdn2.microsoft.com/en-us/library/ms680634.aspx) to close all resources and release the lock on CD/Device.

hanksloka
April 25th, 2007, 10:39 AM
Thanks Krishnaa

Unfortunately, we might have hundreds of threads active which could cause this error. And we can't just assume that it was Nero that triggered the Access Violation.

Also, if Nero crashed we couldn't reliably call the NeroCloseDevice routine to release the handle.

Ideally, we would need a way to test if the CD was locked and force an unlock.

Cheers
Hank

mmscg
April 25th, 2007, 11:13 AM
Send either the
IOCTL_STORAGE_MEDIA_REMOVAL or IOCTL_CDROM_MEDIA_REMOVAL control code
to the CD driver with the DeviceIoControl API function.


PREVENT_MEDIA_REMOVAL pmrCDLock;

// Lock CD-ROM drive
pmrCDLock.PreventMediaRemoval = TRUE;
DeviceIoControl (hCD, IOCTL_STORAGE_MEDIA_REMOVAL,
&pmrCDLock, sizeof(pmrCDLock), NULL,
0, &dwNotUsed, NULL);

// Unlock CD-ROM drive
pmrCDLock.PreventMediaRemoval = FALSE;
DeviceIoControl (hCD, IOCTL_STORAGE_MEDIA_REMOVAL,
&pmrCDLock, sizeof(pmrCDLock), NULL,
0, &dwNotUsed, NULL);

Mitsukai
April 25th, 2007, 02:20 PM
Thanks Krishnaa

Unfortunately, we might have hundreds of threads active which could cause this error. And we can't just assume that it was Nero that triggered the Access Violation.

Also, if Nero crashed we couldn't reliably call the NeroCloseDevice routine to release the handle.

Ideally, we would need a way to test if the CD was locked and force an unlock.

Cheers
Hank

what krishnaa sayd was not wrong, even if nero "crashes"

using atexit should work to.

//JP added flex table