简体   繁体   English

Shell API复制文件夹中的所有文件?

[英]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 ,特别是CopyItemCopyItems方法。 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.

相关问题 Shell脚本复制所有文件和子目录-带有空格的文件夹名称 - Shell Script Copy All Files and Subdirectories - Folder Names With Spaces 一个shell脚本来复制一个文件夹及其所有子文件夹,但请注意它是文件 - a shell script to copy a folder and all it's subfolders, but noit it's files Shell脚本将目录中的所有文件复制到指定的文件夹 - Shell Script to copy all files in a directory to a specified folder [Unix] [Shell脚本]将所有文件从一个文件夹复制到另一个文件夹 - [Unix][Shell Script] Copy all files from one folder to the other Shell命令,如何复制文件夹中的较新文件? - Shell command, how to copy newer files in a folder? shell如何对目录中的所有文件应用功能并将结果复制到另一个文件夹中? - shell how to apply a function to all the files in the directory and copy in another folder the results? 如何使用Windows Shell将使用脚本找到的所有文件复制到另一个文件夹 - How to copy all files found with script to another folder using Windows Shell BASH:将一个文件夹的所有文件复制到另一个文件夹 - BASH: copy all the files of a folder to other folder Shell脚本可提取目录及其子目录中的所有zip文件,并将提取的文件复制到具有相同层次结构的另一个文件夹中 - Shell script to extract all zip files in a directory and its sub directory, and copy the extracted files into another folder with same hierarchy 文件夹中所有文件的Shell命令(macOs) - Shell command for all files in a folder (macOs)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM