小编Nik*_*dev的帖子

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

我目前正在实现一个浏览器帮助程序对象,它允许将Outlook中的电子邮件拖到Internet Explorer的页面上.

我正在按照以下帖子中描述的方法:从MS Outlook实现拖放功能到我们的Web应用程序中.我有它工作但只在x64机器上.在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(); …
Run Code Online (Sandbox Code Playgroud)

c# outlook internet-explorer interop bho

5
推荐指数
1
解决办法
712
查看次数

标签 统计

bho ×1

c# ×1

internet-explorer ×1

interop ×1

outlook ×1