如何在C#ActiveX中实现异步文件下载

时间:2011-01-14 18:36:30

标签: c# c++ activex

我正在C#中重新实现C ++ ActiveX控件。

C ++版本使用继承自CDataPathProperty的属性类。以下代码应如何在C#中查看?

class CFileProperty : public CDataPathProperty
{
 DECLARE_DYNAMIC(CFileProperty )
    ...
}

任何参考赞赏。

我实际上要做的是:ActiveX在IE中托管在对象标记内:

<object type="application/content-type" data="path-or-url-to-file">
    <PARAM name="Url" value="path-or-url-to-file" />
</object>

所以IE应该自己下载文件并将其提供给ActiveX。我必须确保文件没有下载两次!当然,我希望得到一个解决方案,其中使用data参数并且url参数已过时。

1 个答案:

答案 0 :(得分:0)

我在C#中找不到CDataPathProperty conterpart。所以我一直在寻找另一种方法。

为了正确处理具有内容类型和数据属性的对象标记,可以实现IPersitMoniker。唯一相关的方法是Load。

 public void Load(int fFullyAvailable, IMoniker pmk, IBindCtx pbc, uint grfMode)
 {
     if (pmk == null)
         throw new ArgumentNullException("pmk");

     string url;
     pmk.GetDisplayName(null, null, out url);

     // Use the moniker to download the persisted data
     // and obtain an IStream on that data
     Guid iid = InterfaceID.IID_IStream;
     object pStream;
     pmk.BindToStorage(pbc, null, ref iid, out pStream);

     // do whatever you want with the data inside pStream
     ...
}