Search code examples
androidwinapiwindows-servicesmtpplug-and-play

Accessing the files of the Plug and Play android device via WIN API


Let me keep my explanation simple. I am writing a simple windows service, to detect android devices connected to the computer via USB and access the device's memory to read camera photos.

Using RegisterDeviceNotification() in the WIN API we can get registered to get notified for any device change (Devices added/removed from the computer). In my case I register to get notified when the USB devices are connected to the computer. So when a volume device is connected we can get the drive letter using dbcv_unitmask from the PDEV_BROADCAST_VOLUME structure. This works absolutely well for a USB drive. I can then access my USB drive because of the known drive letter.

But, in my case the android device connects using MTP protocol and windows does recognize a new USB device being attached but does not seem to assign a drive letter to it. So, now I have no way to access the memory of the device programmatically.

Please let me know if there is a way to access the android PNP device via WIN API.

Thanks!


Solution

  • So, the alternative was to use WPD (Windows portable device API ) to access the mtp device.