struct mcsEvent4Device_t{
char device[64];
int     type;
int state;
        int param;
};
struct mcsEvent4Agent_t{
int state;
char agent[64];
char device;//LoginDevice OR Queue
int param;//Reason
};
struct mcsEventServiceInitiated_t{
char station[64];
char callid[32];
};
struct mcsEventOrignated_t{
char alerting[64];
char caller[64];
char calling[64];
char calleed[64];
char callid[32];
};
struct mcsEventDelivered_t{
char alerting[64];
char caller[64];
char router[64];
char calling[64];
char calleed[64];
char callid[32];
};
struct mcsEventConnectionClear_t{
char dropDevice[64];
char callid[32];
int reason;
};
struct mcsEventCallClear_t{
char callid[32];
int reason;
};
struct mcsEventCallActive_t{
char callid[32];
char actionDevice[64];
char heldDevice[64];
char calling[64];
char calleed[64];
};
struct mcsEventCallHeld_t{
char callid[32];
char actionDevice[64];
char heldDevice[64];
char calling[64];
char calleed[64];
};
struct mcsEventCallTransfered_t{
char newcall[32];
char actionDevice[64];
char heldcall[32];
char heldDevice[64];
char activecall[32];
char activeDevice[64];
char calling[64];
char calleed[64];
};
struct mcsEventCallEstanblished_t{
char callid[32];
char firstDevice[64];
char secondDevice[64];
char calling[64];
char calleed[64];
};
struct mcsEvent4Call_t{
int code;
union{
mcsEventServiceInitiated_t serviceInitiated;
mcsEventOrignated_t orignated;
mcsEventDelivered_t delivered;
mcsEventConnectionClear_t connClear;
mcsEventCallClear_t callClear;
mcsEventCallActive_t callActive;
mcsEventCallTransfered_t callTransfered;
mcsEventCallHeld_t callHeld;
mcsEventCallEstanblished_t callEstanb;
}u;};
struct mcsEvent4Media_t{
};
struct mcsEvent_t{
int code;
char timestamp[64];
union{
mcsEvent4Device_t deviceEvt;
mcsEvent4Agent_t agentEvt;
mcsEvent4Call_t callEvt;
mcsEvent4Media_t mediaEvt;
}u;
};extern "C" __declspec(dllexport) int mcsGetEvent(mcsEvent_t &event);
请问在C#中如何调用mcsGetEvent这个函数

解决方案 »

  1.   

    DllImport所在的名字空间 using System.Runtime.InteropServices; DllImport("加上相应的动态链接库如MyDLL.dll,")]
            private static extern int mcsGetEvent(mcsEvent_t &event); 
      

  2.   

    建议还是别折腾了
    用C++/CLI封装一下接口
      

  3.   

    using System.Runtime.InteropServices;
    DllImport导入DLL文件参考
    参考
      

  4.   

    http://topic.csdn.net/u/20090413/09/ae600faf-5a31-4cc1-836a-98bbae25ca46.html
    参考
      

  5.   

    http://blog.csdn.net/null1/archive/2009/03/03/3953155.aspx
      

  6.   

    你的问题主要就是平台调用过程中的数据封送问题。楼上有人已经给出了正确的答案。但是如果只获得答案,不知道原理,以后遇到了此类问题还是不知道如何下手。如果你想系统学习如何进行数据封送,我推荐你阅读刚刚出版的新书:《精通.NET互操作P/Invoke,C++Interop和COM Interop》,这本书的第2章“数据封送”详细介绍了平台调用中的数据封送过程,非常详细,我就是读完后才搞清楚平台调用中的封送处理。 
    该书的官方网站: 
    www.interop123.com 豆瓣网信息: 
    http://www.douban.com/subject/3671497/