c# DLL接口回调函数
来源:互联网 发布:易语言源码大全下载 编辑:程序博客网 时间:2024/04/30 20:30
一:回调函数
1:DLL内部
//声明回调函数
typedef void (CALLBACK* ONSERIESDATA)(BYTE* buf, DWORD dwBufLen, DWORD dwTime, bool bDown);
//DLL接口中的传入回到函数
extern "C" __declspec(dllexport) void WINAPI Enable_Listening(ONSERIESDATA pSeriesCallBack);
//引入地址
void WINAPI Enable_Listening(ONSERIESDATA pSeriesCallBack)
{
gSeriesCallBack = pSeriesCallBack;
}
//回调函数调用
if (gSeriesCallBack != NULL)
{
gSeriesCallBack(frameBuf, currentFrameLen, time, false);
}
2:C# 上层
//声明委托,
public delegate void ONSERIESDATA(IntPtr buf, UInt32 dwBufLen, UInt32 dwTime, Boolean bDown);
//导出接口
[DllImport(strDllPath)]
public static extern void Enable_Listening(ONSERIESDATA pSeriesCallBack);
//函数邦定
private RSUComm.ONSERIESDATA pSeriesCallBack = new RSUComm.ONSERIESDATA(ShowSeriesMessage);
//注意,静态函数不可以直接更新控件,需借助UpdateControlEventHandler
private delegate void UpdateControlEventHandler(Object sender, FireEventArgs e);
private static event UpdateControlEventHandler UpdateListViewControl;
UpdateListViewControl += new UpdateControlEventHandler(this.UpdateListView);
private static void ShowSeriesMessage(IntPtr pBuf, UInt32 iBufLen, UInt32 iTime, Boolean bDown)
{
UpdateListViewControl(g_Form.pubSeriesListeningForm, new FireEventArgs(StringOut));
}
//显示信息
public void UpdateListView(Object o, FireEventArgs e) //事件处理函数,用来更新控件
{
delegateUpdateListViewTagResult(e.room);
}
//停止回调
RSUComm.Enable_Listening(null);
//启用回调
RSUComm.Enable_Listening(pSeriesCallBack);
//声明类
public class FireEventArgs : EventArgs
{
public FireEventArgs(string room)
{
this.room = room;
}
public string room;
}
- c# DLL接口回调函数
- c# DLL接口回调函数
- c#调用c++dll接口及回调函数
- C# 调用dll 回调函数
- C#调用c++dll时,关于回调函数
- C#委托实现C++ Dll中的回调函数
- C# 回调函数
- C#回调函数
- C#回调函数
- C#回调函数
- C#回调函数
- C#回调函数
- C#回调函数
- C#回调函数
- C# 回调函数
- C#回调函数
- C# 回调函数
- C#调用dll,dll中执行C#端的回调函数
- 关于weblogic的自动部署不能生效的问题(转载)
- 文件上传控件浏览按钮只读
- 创建和使用dll动态链接库(dll系列一)
- 【题目28】一些简单题的算法练习题(2)
- ResetEvent()
- c# DLL接口回调函数
- Asp.Net 控件开发之属性转换器
- JS格式化日期JS类
- ORACLE实例的后台进程
- 0x800A0E7A ,0x80040154, ADO连接错误
- VC++初学感慨
- 拨“云”见日
- 博客开张 大家多多关照
- meta 使用大全