开发者

WinApi ShellExecuteEx - using verb 'copy' on a file list

is it possible to use ShellExecuteEx to copy or cut a group of files in a given directory ? The Windows function works fine on a single file but I can't find anywhere any tips over the subject (with a file list).

I don't expect any alternative method ( such as xcopy) because I need the windows shell function undo/redo after performing shell-item-specific actions.

It's not documented at all in the microsoft msdn library. I've tried to fill the 'lpfile' parameter with a list of items such as PChar("Drive:\file1.fileExt","Drive:\file1.fileExt") and other such common list format... but nothing to do, shellExecuteEx return a value < 33.

Is there a verb such as 'select' or 'addtoselection' ? Should the flag SEE_MASK_IDLIST be added and in this case is an ITEMIDLIST Structure able to define a file list on which the ShellExecuteEx verb will be开发者_开发知识库 executed ?


Yes, its possible, but why execute external command if Windows API has built-in functions to do that? For copy/cut operation, I recommend you to use SHFileOperation(), Microsoft has provided a code example for that purpose.

Alternatively, you can also use CopyFileEx() to copy files, and use MoveFile() to move files. They are faster than SHFileOperation().


You are right, SHFileOperation are extreamely simplier to use (in comparison to shellexexuteex), however the behaviour of this function is a bit different. If you perform a SHFileOperation such as copy or cut in an application, if you get back directly to the Windows explorer, the 'paste' context menu item is not avalaible. It seems the shell is operating in another way than with whellexecuteex. With a ShellExecuteEx performed in an application and ion a single file, the explorer enable directly the 'paste' item.

Anyway the WinApi/ShellApi is not very clear about that because in summary there many ways to copy file(s): - SHellExecuteEx with verb 'copy' - SHFileOperation - ClipBoard: when simulating a file drop event...

But in any ways the behaviour of the undo/redo shell context item is similar to the explorer process. - ShellExecuteEx enable well the undo/redo features but only operates on singles file (or not documented) - SHFileOperation enable to work on a file list (as you were saying, separated by a #0, end list a double #0. but the SHell context menu seems not to be linked as deeply as ShellExecuteEx to the operation. - Clipboard: also allows file list but not all behaviour ( copy only, not paste). because 'paste' seems to be more a kind of drag drop move operation, not a clipboard one, even if the ShellApi Specifies that it's a bit the same...they are using special structures not used anywhere else...

Synthesis: it's not clear at all. The windows api provides at leat 3 way to operates on files but if we talk about a file list, it's less logical, and even a nightmare: you have to deal with the old struct that nobody use except the 3 guys at Microsoft who are still working on shell features...(or not).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜