Any API function for device detection.

is there any kind of function on windows API which will help me to know if there a device is connected or disconnected.
for example detecting a mass storage device(pen drive) is removed or attached.
You just need a top-level window (visible or invisible) that processes the WM_DEVICECHANGE. See http://msdn.microsoft.com/en-us/library/windows/desktop/aa363480(v=vs.85).aspx for details on the event information.

For pen drives and similar, you don't have to do anything but listen to the message. I think that this message works for other hardware too, but you have to register to receive messages from them... I THINK. Haven't needed it so I think I forgot already about what I read once upon a time.
That worked well.
thank you.
Topic archived. No new replies allowed.