我正在構建一個IE插件,我想「是」外部對象。因此我使用SetUIHandler將我的類設置爲UIHandler。AddFavorite在c#中實現IShellUIHelper時不工作#
我執行的IDocHostUIHandler(引用到Microsoft Internet控件(COM對象)),並在GetExternal我回到我的課:
public void GetExternal(out object ppDispatch)
{
ppDispatch = this;
}
這個偉大的工程。任何其他選項都不是我感興趣的,所以我需要返回E_NOTIMPL。
例如:
public void TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID)
{
Marshal.ThrowExceptionForHR((int)WinAPI.HRESULT.E_NOTIMPL);
}
的偉大工程,但我也需要實現IShellUIHelper(IE指望它從UIHandler)。
,然後當我實現添加到收藏夾:
public void AddFavorite(string URL, ref object Title)
{
Marshal.ThrowExceptionForHR((int)WinAPI.HRESULT.E_NOTIMPL);
}
它不工作(js的獲得和錯誤)。
當我試圖做同樣的在C++,並返回E_NOTIMPL爲返回值,一切都很正常:
STDMETHODIMP CMyClass::AddToFavoritesBar(BSTR URL, BSTR Title, VARIANT *Type)
{
return E_NOTIMPL;
}
我也試圖與throw new COMException("", (int)WinAPI.HRESULT.E_NOTIMPL);
更換Marshal.ThrowExceptionForHR((int)WinAPI.HRESULT.E_NOTIMPL);
,它仍然不起作用。
任何人都可以幫助我嗎?
感謝,
歐米
拋出NotImplementException,它將轉換爲E_NOTIMPL。 –
這不起作用 – Omri