Automatically updating drives collection

vbimport

#1

Hi everyone,

I am creating an application in C# - so far so good except for one niggling issue.

This application is likely to run on a laptop which may occassionally have an external USB DVD-R/RW drive attached. I would like to be able to detect a newly plugged-in USB drive while the application is still running.

I have done the usual populating of a Drives collection through the NeroClass.getDrives method. I call this method again soon after plugging the drive in but nothing happened. The Drives collection did not increase to include the newly plugged-in drive!

I noticed that Nero automatically lists the new drive in the dropdownlist/combobox, so obviously this is possible. Can someone please tell me how the API can let me do this?

Any suggestions would be greatly appreciated.

Cheers,
Dany.


#2

By calling EnableDriveChangeCallback() on a Nero object you will be notified each time a drive is added or removed with the OnDriveStatusChanged() event.

In the event handler, get the new drives collection and search for your drive using the hostID and targetID (you will find a drive only if it is added).


#3

Hi there,

Thanks for the reply. I added an extra line of code like this:

nero.EnableDriveChangeCallback(true); //nero is the name of the NeroClass object.

Unfortunately this line failed with an error message saying: “Cannot register callback”.

Any ideas what this may mean? Did I call the method incorrectly?

Cheers,
Dany.


#4

Whoops - nevermind. Got it sorted now. For some reason I cannot call that method prior to calling .GetDrives method for the first time. Everything works now.