Copy File to MTP lazarus / 34-Windows ---------------------------------------------------------------------- bambamns · 2019-02-24 10:37 Hi, Is it possible to copy local files from PC to MTP device (e.g Android phone) ? FileUtil.CopyFile and Windows.CopyFile can't do it. As I found , it can be done with Copy file to clipboard and Paste it from, but I can't found Lazarus code to do it. Can it be done (anyway) ? Thx ---------------------------------------------------------------------- ASerge · 2019-02-24 18:21 Quote from: bambamns on February 24, 2019, 11:37:54 amIs it possible to copy local files from PC to MTP device (e.g Android phone) ? It's complicated. In short, you need to use the Windows Portable Devices API. Later I will make an example of, and while engaged in the translation of portable API for FPC. ---------------------------------------------------------------------- bambamns · 2019-02-26 02:34 Good news - Example will be helpful Thank you ---------------------------------------------------------------------- dbannon · 2019-02-26 04:33 I concluded this would be quite hard on Linux, the MTP protocol not really a file system. I'd love to see your demo ASerge, especially if its cross platform  Cannot be impossible, the GUI filemangers all do it but ..... Davo ---------------------------------------------------------------------- ASerge · 2019-02-26 09:15 This is not a cross-platform example because I only know the windows api. Very long .h file, so I only translate some things to get the demo (attached) ---------------------------------------------------------------------- Thaddy · 2019-02-26 12:09 Foe linux you can use libmtp with the same functionality. ---------------------------------------------------------------------- dbannon · 2019-02-28 01:33 QuoteFoe linux you can use libmtp with the same functionality. OK, do you know if there exists already some pascal bindings ?  I'd really like to see it work..... Wow, it comes with some nice docs too, and C examples ..... Davo ---------------------------------------------------------------------- dbannon · 2019-02-28 02:36 http://www.bakooa.com/libmtp-pascal/ The web page is not in English, perhaps French ?  (please forgive my abysmal ignorance). Code has not been touched since 2010 but looks to be clearly written ...... very interesting .... Davo ---------------------------------------------------------------------- bambamns · 2019-03-01 03:04 @ASerge Thank you. This is good example for folder listing , but I still cannot find a way to copy to and from a mobile device. Am I missing something, because I can't find in uWrapper copy or something like copy to use ? Thank you again. ---------------------------------------------------------------------- bambamns · 2019-03-01 03:14 I found on stackoverflow : QuoteYou can use MOUNTVOL command to mount the USB drive, identified by its GUID, on a specific mount point, independently of the available drive letters.  MOUNTVOL C:\XOOM \\?\Volume{a000351d-dbaa-11e0-bdaa-020255061358}\ and then  copy file.ext c:\XOOM\directory\file.ext It looks it can be done, but I can't do it with GUID's I have found on my PC. ---------------------------------------------------------------------- ASerge · 2019-03-01 18:13 Quote from: bambamns on March 01, 2019, 04:14:23 amQuoteYou can use MOUNTVOL command to mount the USB drive, identified by its GUID, on a specific mount point, independently of the available drive letters. MOUNTVOL is an NTFS mount point tool. MTP is a media transfer protocol that is too far from NTFS. Specify what type of connection you want to use. ---------------------------------------------------------------------- bambamns · 2019-03-02 12:21 Finally I have wrote a Power Shell script and convert it to exe so it can be run with TProcess. Major guidelines are PS script :  - make new object as a com shell application  - map Android with NameSpace(0x11)  - map file and folder to copy  - use CopyHere to copy file from and to Android Helpful links : PowerShell MTP https://blog.daiyanyingyu.uk/2018/03/20/powershell-mtp/ PS2EXE https://gallery.technet.microsoft.com/scriptcenter/PS2EXE-GUI- Convert-e7cb69d5 Thanks to all for help ---------------------------------------------------------------------- Thaddy · 2019-03-02 13:16 Quote from: ASerge on March 01, 2019, 07:13:53 pmMOUNTVOL is an NTFS mount point tool. MTP is a media transfer protocol that is too far from NTFS. Specify what type of connection you want to use. Well, the library I mentioned (libmtp) also implements MTP on top of NTFS .... I have just not seen Pascal headers for MTP. MTP is a protocol, not a filesystem. ---------------------------------------------------------------------- dbannon · 2021-01-18 11:31 OK, a 12 month old thread but a very good one .... ASerge, I was wondering if you have further developed your slick Windows MTP interface posted further up this thread ? Its pretty neat, works perfectly at what it does do but with my very limited knowledge of Windows API, not something I can develop. I would really like to be able to copy a file to a 'Device', bring back one back from a Device or delete a file there. Davo ---------------------------------------------------------------------- ASBzone · 2021-01-18 16:07 Quote from: dbannon on January 18, 2021, 12:31:09 pmOK, a 12 month old thread but a very good one .... Davo You mean 24 month old thread... ---------------------------------------------------------------------- dbannon · 2021-01-19 00:24 Quote from: ASBzone on January 18, 2021, 05:07:44 pmYou mean 24 month old thread... yep, you are right.  Maybe I am trying to make out 2020 did no exist ? Davo