views:

26

answers:

1

When a volume is attached to file system, on Windows,
the Window explorer detects the volume and refreshes automatically.

I wonder the technique.
How do an program(include device driver) get the notification?
-Of course, it doesn’t mean a polling. I want to get an event(or a message).

I would like to get the notification when a network volume(like SMB) is attached.
Thanks in advance.

+1  A: 

You're going to have to do some research, but basically you just need to register with the Windows IO Manager so that when the device is connected, some part of your code is called. RegisterDeviceNotification() is probably a good place to get started. When the device is connected, the IO Manager will send you a message, so you should make sure you have a proper callback setup for the message.

It would not hurt to read up on Windows Devices Services from the Windows System API. Depending on what you are doing, you may or may not need a driver as the generic driver provided by Microsoft is often good enough. For drivers, check out the Windows Driver Kit, it contains an excellent collection of sample drivers, as well as Win32 code for interfacing with drivers and working with hardware.

Good luck!

Dr. Watson
Thanks Dr. Watson! :)
Benjamin