简体   繁体   English

通过BHO从outlook拖放到Internet Explorer可以在x32 / 86机器上运行

[英]Drag/drop from outlook to internet explorer via BHO doesn't work on x32/86 machines

I'm currently implementing a browser helper object which would allow dragging emails from the outlook to the internet explorer's page. 我目前正在实现一个浏览器帮助程序对象,它允许将Outlook中的电子邮件拖到Internet Explorer的页面上。

I'm following the approach described in the following post: Implementing a Drag-and-Drop function from MS Outlook into our web application . 我正在按照以下帖子中描述的方法: 从MS Outlook实现拖放功能到我们的Web应用程序中 I've got it working but only on x64 machines. 我有它工作但只在x64机器上。 On the x32/86 machines i'm getting the exception in the following piece of code (obviously i've replaced real filename inserting with fake one for simplicity): 在x32 / 86机器上,我在下面的一段代码中得到了例外(显然我为了简单起见用真假文件替换了真正的文件名插入):

DropFiles df = new DropFiles();

string filename = @"D:\projects\hello.txt";
byte[] binaryData = Encoding.Unicode.GetBytes(filename);

binaryData = binaryData.Concat(new byte[] { 0, 0 }).ToArray();

IntPtr pointerToGlobalMemory = Marshal.AllocHGlobal(Marshal.SizeOf(df) + binaryData.Length);

df.Files = Marshal.SizeOf(df);
df.Wide = true;
Marshal.StructureToPtr(df, pointerToGlobalMemory, true);
IntPtr newPointer = new IntPtr(pointerToGlobalMemory.ToInt32() + Marshal.SizeOf(df));

Marshal.Copy(binaryData, 0, newPointer, binaryData.Length);

var descriptorFormat = new COMInterop.FORMATETC();
descriptorFormat.cfFormat = HdropDescriptorId; // 15
descriptorFormat.ptd = IntPtr.Zero;
descriptorFormat.dwAspect = COMInterop.DVASPECT.DVASPECT_CONTENT;
descriptorFormat.lindex = -1;
descriptorFormat.tymed = COMInterop.TYMED.TYMED_HGLOBAL;

var td = new COMInterop.STGMEDIUM();
td.unionmember = pointerToGlobalMemory;
td.tymed = COMInterop.TYMED.TYMED_HGLOBAL;

dataObject.SetData(ref descriptorFormat, ref td, true);

On the executing the last ling of this code (actually setting the fake HDROP descriptor) i'm getting the following exception: "Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))". 在执行此代码的最后一个(实际设置伪HDROP描述符)时,我得到以下异常:“无效的FORMATETC结构(HRESULT异常:0x80040064(DV_E_FORMATETC))”。

Did someone experienced described problem or have an idea what can be the reason of this issue? 有人经历过描述问题或了解这个问题的原因是什么?

To be more specific about environment - i'm having this trouble on win7 32 bit with IE 10 but i'm pretty sure that the reason especially in that machine is 32 bit. 更具体的环境 - 我在使用IE 10的win7 32位上遇到了这个问题,但我很确定特别是那台机器的原因是32位。

您需要实现自己的IDataObject并将其传递给原始IDropTarget.Drop,而不是劫持来自Outlook的现有IDataObject。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM