c# 重写IDispatch接口,有答案时继续加分。

哨子 2011-02-20 12:36:19
[code=C] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IMyInterface2
{
[PreserveSig]
int Invoke(int dispIdMember, [In] ref Guid riid, [In, MarshalAs(UnmanagedType.U4)] int lcid, [In, MarshalAs(UnmanagedType.U4)] int dwFlags, [In, Out] NativeMethods.tagDISPPARAMS pDispParams, [Out, MarshalAs(UnmanagedType.LPArray)] object[] pVarResult, [In, Out] NativeMethods.tagEXCEPINFO pExcepInfo, [Out, MarshalAs(UnmanagedType.LPArray)] IntPtr[] pArgErr);
[PreserveSig]
int GetIDsOfNames([In] ref Guid riid, [In, MarshalAs(UnmanagedType.LPArray)] string[] rgszNames, [In, MarshalAs(UnmanagedType.U4)] int cNames, [In, MarshalAs(UnmanagedType.U4)] int lcid, [Out, MarshalAs(UnmanagedType.LPArray)] int[] rgDispId);
[return: MarshalAs(UnmanagedType.Interface)]
UnsafeNativeMethods.ITypeInfo GetTypeInfo([In, MarshalAs(UnmanagedType.U4)] int iTInfo, [In, MarshalAs(UnmanagedType.U4)] int lcid);
int GetTypeInfoCount();
}[/code]
在网上找了一下资料,并从Reflector中查了一下IDispatch代码,这样写了一下,但总报错。。
不知道哪位有经验或有重写的资料或代码,发一下。
...全文
92 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2011-02-20
  • 打赏
  • 举报
回复
threenewbee 2011-02-20
  • 打赏
  • 举报
回复
顺便说一下,IDispatch 实现的是 COM 里面可以后期绑定的类型,相当于 VB 里面的 Object。
threenewbee 2011-02-20
  • 打赏
  • 举报
回复
IDispatch 包含在 System.Runtime.InteropServices 里面,先引用对应的库,然后加上:
using System.Runtime.InteropServices;

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧