本文介绍了从IfileOperation.GetDisplayName中的IShellItem获取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我挂钩了 IFileOperation CopyItems 方法来监视/拦截Windows中的文件复制。
我的问题是如何从 IShellItem (最后一个CopyItems)检索完整文件名

  function New_CopyItems(p:Pointer; punkItems:IUnknown; psiDestinationFolder:IShellItem):HResult; stdcall; 

psiDestinationFolder 有一个名为 GetDisplayName ,只返回当前文件的文件夹名称开始复制!但我想得到完整的文件名,不知道我应该做什么!有任何其他方法,以帮助我获得全名吗?

解决方案

CopyItems 方法可能潜在地复制多个项目。所以,就在你蝙蝠你错了寻找一个单一的文件名。这是一个非常复杂的API,您需要阅读仔细地理解函数的工作原理。



psiDestinationFolder 参数是 IShellItem 标识目标。使用 GetDisplayName 方法获取文件路径。



另一个参数 punkItems 更复杂。它被记录如下:

告诉你可能有一个 IShellItemArray IDataObject IEnumShellItems 接口的 IUnknown 接口后面的 IPersistIDList 并且在该单个对象中可以有多个项目,每个项目都被复制到目标文件夹。您需要依次查询 punkItems 的每个可能的界面,直到找到您必须处理的这些可能性。然后用特殊的代码处理每一个。为了测试这个,你需要编写代码,调用 CopyItems 与每个可能的接口。你会发现如何做到这一切从四个接口的每一个的文档。如果你还不知道shell编程和COM,希望在你完成这项工作的时候这样做。



最后,我怀疑这是一个很好的检测文件复制的方式。使用许多不同的API复制文件。 IFileOperation.CopyItems 只是其中之一。如果你只钩 IFileOperation.CopyItems ,那么你会错过很多文件复制操作。


I hooked the CopyItems method of IFileOperation to monitor/intercept file copy in windows.My problem is how can i retrieve the full file name from IShellItem(last param of CopyItems)

function New_CopyItems(p: Pointer; punkItems: IUnknown;psiDestinationFolder: IShellItem): HResult; stdcall;

The psiDestinationFolder have a method called GetDisplayName that return only the folder name of current file was begin copied!! But i want to get full file name and don't know what i should to do !? There is any other method to help me getting full name ?? Or i have to using another API ....?

Excuse me if my English is bad!

解决方案

The CopyItems method copies potentially multiple items. So right off the bat you are mistaken looking for a single file name. This is a very complex API and you do need to read the documentation carefully and understand clearly how the function works.

The psiDestinationFolder parameter is an IShellItem that identifies the destination. Use the GetDisplayName method to get the file path.

The other parameter, punkItems is more complex. It is documented like this:

This is telling you that there could be an IShellItemArray, IDataObject, IEnumShellItems or a IPersistIDList object behind the IUnknown interface that you receive. And that there could be multiple items in that single object, each one to be copied to the destination folder. You will need to query punkItems for each possible interface in turn until you find out which of these possibilities you have to deal with. And then handle each one with special code. In order to test this you'll need to write code that calls CopyItems with each of the possible interfaces. You'll find out how to do all of this from the documentation of each of the four interfaces. If you don't already know shell programming and COM well, expect to do so by the time you complete this work.

Finally, I doubt that this is a very good way to detect file copying. Files are copied using many different APIs. And IFileOperation.CopyItems is but one of them. If you only hook IFileOperation.CopyItems then you'll miss a lot of file copy operations.

这篇关于从IfileOperation.GetDisplayName中的IShellItem获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 02:01