[英]Shell API to copy all files in a folder?
I am using FreePascal/Lazarus, and I am trying to find the correct ShlObj/ShellApi calls to copy all files from a Device's DCIM Folder (ie a Camera) to another folder on the filesystem. 我正在使用FreePascal / Lazarus,并且我试图找到正确的ShlObj / ShellApi调用,以将所有文件从设备的DCIM文件夹(即相机)复制到文件系统上的另一个文件夹。
Here is the code to select to select the device: 这是选择设备的代码:
r:= ShlObj.SHBrowseForFolder(x);
But from, there all I have is r, which is a LPITEMIDLIST
variable. 但是从那里,我只有r,它是LPITEMIDLIST
变量。
Does anyone know the correct code to copy all files inside the Device's DCIM Folder 'r', to a destination folder (ie strDest)? 是否有人知道将设备的DCIM文件夹“ r”内的所有文件复制到目标文件夹(即strDest)的正确代码?
Note: I must use the ShellApi/ShlObj interface to do the copying 注意:我必须使用ShellApi / ShlObj接口进行复制
I assume that the PIDL specifies an item that is part of the file system, but I believe that is what you intend since you go on to say "copy all files". 我假设PIDL指定了一个文件系统中的项目,但是我相信这就是您想要的,因为您继续说“复制所有文件”。 In which case, call SHGetPathFromIDList
to obtain the file system path from the PIDL, and then call SHFileOperation
to copy the files. 在这种情况下,请调用SHGetPathFromIDList
以从PIDL中获取文件系统路径,然后调用SHFileOperation
来复制文件。
If you want to perform copying at the shell level, and not be restricted to files, then it's a little more complex. 如果要在外壳程序级别执行复制,而不是仅限于文件,则要复杂一些。 Probably the simplest will be to use IFileOperation
, specifically the CopyItem
and CopyItems
methods. 可能最简单的方法是使用IFileOperation
,特别是CopyItem
和CopyItems
方法。 You'll need to be able to go from a PIDL to an IShellItem
which can be done with SHCreateItemFromIDList
. 您需要能够从PIDL转到IShellItem
,这可以通过SHCreateItemFromIDList
完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.