挂钩资源管理器拖放失败 [英] hooking explorer drag drop fails

查看:473
本文介绍了挂钩资源管理器拖放失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大的图片:我试图注入自己的包装探险家的拖曳。我的代码被注入到资源管理器中,我尝试用我自己的替换掉目标。

The big picuture: I am trying to inject my own own wrapper around explorer's drag n drop. My code is injected into explorer, and I try to replace the drop target with my own.

为了这样做,我做:


  1. 查找所有资源管理器窗口(使用EnumWindows并检查每个窗口的进程关联)。

  2. 对于每个窗口,我运行以下(do nothing)code:




IDropTarget * lpDT =(IDropTarget *)GetProp(hwnds [i] ,LOleDropTargetInterface); // get existing drop target

IDropTarget* lpDT = (IDropTarget *)GetProp(hwnds[i], L"OleDropTargetInterface"); //get existing drop target

HRESULT res1 = :: RevokeDragDrop(hwnds [i]); // revoke existing drop target

HRESULT res1 = ::RevokeDragDrop(hwnds[i]); //revoke existing drop target

HRESULT res2 = :: RegisterDragDrop(hwnds [i],lpDT); //并重新注册放置目标

HRESULT res2 = ::RegisterDragDrop(hwnds[i], lpDT); //and re-register the drop target

现在,代码不会更改放置目标。我只是取消注册和重新注册相同的目标。

For now, the code does not change the drop target. I am simply un-registering and re-registering the same target.

在所有资源管理器窗口上运行它后,我得到res1 ==应用程序调用了一个接口,为不同的线程编组。

After running it on all explorer windows I get res1 == "The application called an interface that was marshalled for a different thread." for every window I find.

如果我忽略错误(只是为了测试),并继续更换,然后浏览器停止拖动桌面上的文件更改图标位置)。 Btw,令人惊讶的是,在两个不同的文件夹之间拖动文件仍然可以工作。

If I ignore the error (just for testing), and go ahead with replacement, the then explorer stops dragging files on the desktop (just to change the icon location). Btw, surprisingly, dragging files between 2 different folders still works.

我的代码是从浏览器线程运行的(注入到资源管理器)。

My code is running from an explorer thread (injected into explorer).

有什么办法解决这个问题吗?

Is there any way around this problem?

推荐答案

GetProp返回一个指针,关心编织它(纯指针)。正如在答案,虽然我得到一个指针放置目标,它不是真正的封送我的线程。
我可以告诉你,在指针上调用revokeDragDrop(即使它不是真的属于我的线程)是在搞定放置目标,然后失败。

The GetProp returns a pointer to the drop target without caring about marshaling it (pure pointer). As pointed out to me in this answer, although I am getting a pointer to the drop target, it is not really marshaled to my thread. I can tell you that calling revokeDragDrop on the pointer (even if it did not really belong to my thread) was messing up the drop target, and then failing.

因为我没有办法从其他线程拿到它的下降目标,我放弃了,并采取了另一条路线。

Since I have no way of obtaining the drop target from the other thread holding it, I gave up on this and took an alternate route.

这篇关于挂钩资源管理器拖放失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆