2011-01-14 24 views
0

我正在C#中重新實現C++ ActiveX控件。如何在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。我必須確保文件不會被下載兩次!當然,我將不勝感激解決方案,其中使用數據參數,並且url參數已過時。

回答

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 
    ... 
}