C#调用C++回调函数的问题


C++的回调函数中有一个参数是,是返回一个字符串,原则如下:
typedef   void   (*TDataEvent)(char   *AData   ,int   ALen);
其中char   *AData是从DLL中返回一个字符串,串的内存已经在DLL中分配了

下面中我在C#中定义的委托
public   delegate   void   TDataEvent(Byte[]   AData,   int   ALen);

下面是回调函数的设置代码:
Event   =   new   clReceivelDllPoxy.TDataEvent(getDate);
ReceDllPoxy.AddServer(1024,   Event,   2);
其中   Event是上面委托的实例,我定义成一个成员这样就不会被自己释放

下面是C#中回调函数的实现
public   void   getDate(byte[]   AData,   int   ALen)
{
//发现每次回调是   AData只有一个字节
}

下面转载一个别人的代码,谢谢

c#,委托,回调,事件,系列,一,using System;
c#,委托,回调,事件,系列,一,
using System.Collections.Generic;
c#,委托,回调,事件,系列,一,
using System.Text;
c#,委托,回调,事件,系列,一,
using System.Runtime.InteropServices;
c#,委托,回调,事件,系列,一,
using System.Reflection;
c#,委托,回调,事件,系列,一,
using System.Reflection.Emit;
c#,委托,回调,事件,系列,一,
c#,委托,回调,事件,系列,一,
namespace AppDllTest

相关文章: