c++winapiusbwpd

Windows Portable Device - Notify when a new file is created / copied / deleted


Is it possible to be notified when a file is deleted from / copied to / storage device using (IPortableDeviceEventCallback).

So far i've only been notified when the flash drive was disconnected or its name was changed externally by the user.

Edit: I'm interested in receiving the WPD_EVENT_OBJECT_ADDEDevent.

IPortableDeviceCapabilities::GetSupportedEvents

shows that the needed event is supported, but nothing is sent upon new file copy


Solution

  • WPD_EVENT_OBJECT_ADDED corresponds to MTP event ObjectAdded. https://msdn.microsoft.com/en-us/microsoft-r/dn932706

    I think that what events are really sent depends on concrete implementation of MTP protocol on concrete portable device.

    I beleave that WPD API main purpose is to manage portable devices like a phones and music players, access and methods to work with usb flash drives are only exported as some layer of compatibility, and may not contain all functions.

    If you want to receive such notifications not from portable devices implements MTP, but only from USB flash drives, you should take a look for example on filesystem minifilters https://msdn.microsoft.com/en-us/windows/hardware/drivers/ifs/file-system-minifilter-drivers

    They could give you needed callbacks.