在C#中调用dll接口函数:
申明:
[ DllImport( "c:\\NMS\\bin\\cta.dll" )]
public static extern uint ctaOpenServices(uint ctahd, ref CTA_SERVICE_DESC [] svclist,uint nsvcs);调用:
service_count = 0;
services[service_count].name.svcname = "ADI";
services[service_count].name.svcmgrname = (BoardType == DevLib.QX_BOARD ) ? "QDIMGR" : "ADIMGR";
services[service_count].mvipaddr.board = board;
services[service_count].mvipaddr.stream = stream;
services[service_count].mvipaddr.timeslot = timeslot;
services[service_count].mvipaddr.mode = DevLib.ADI_FULL_DUPLEX; service_count += 1;
//和上面类似
service_count += 1;//和上面类似 service_count += 1;
//和上面类似
service_count += 1;
status = DevLib.ctaOpenServices ( outcontext, ref services , service_count);
此时
根据debug跟踪的结果,发现执行最后一句以后services 的长度被吃掉了,变成了Length = 0x1,这样status结果也不是我需要的了!,请高手救助!/////相关结构:
public struct CTA_SERVICE_DESC
{
public CTA_SERVICE_NAME name;
public CTA_SERVICE_ADDR svcaddr;
public CTA_SERVICE_ARGS svcargs;
public CTA_MVIP_ADDR mvipaddr;
} ;
public struct CTA_SERVICE_NAME
{
public string svcname; /* name of service */
public string svcmgrname; /* name of service manager */
} ;
public struct CTA_SERVICE_ADDR
{
public string addr;
public uint host;
public uint reserved;
};
[ StructLayout( LayoutKind.Sequential )]
public struct CTA_SERVICE_ARGS
{
public string strarg ;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=10 )]
public uint [] args ;
} ;
public struct CTA_MVIP_ADDR
{
public uint board;
public uint bus;
public uint stream;
public uint timeslot;
public uint mode;
} ;public CTA_SERVICE_DESC [] services = new CTA_SERVICE_DESC [4];
申明:
[ DllImport( "c:\\NMS\\bin\\cta.dll" )]
public static extern uint ctaOpenServices(uint ctahd, ref CTA_SERVICE_DESC [] svclist,uint nsvcs);调用:
service_count = 0;
services[service_count].name.svcname = "ADI";
services[service_count].name.svcmgrname = (BoardType == DevLib.QX_BOARD ) ? "QDIMGR" : "ADIMGR";
services[service_count].mvipaddr.board = board;
services[service_count].mvipaddr.stream = stream;
services[service_count].mvipaddr.timeslot = timeslot;
services[service_count].mvipaddr.mode = DevLib.ADI_FULL_DUPLEX; service_count += 1;
//和上面类似
service_count += 1;//和上面类似 service_count += 1;
//和上面类似
service_count += 1;
status = DevLib.ctaOpenServices ( outcontext, ref services , service_count);
此时
根据debug跟踪的结果,发现执行最后一句以后services 的长度被吃掉了,变成了Length = 0x1,这样status结果也不是我需要的了!,请高手救助!/////相关结构:
public struct CTA_SERVICE_DESC
{
public CTA_SERVICE_NAME name;
public CTA_SERVICE_ADDR svcaddr;
public CTA_SERVICE_ARGS svcargs;
public CTA_MVIP_ADDR mvipaddr;
} ;
public struct CTA_SERVICE_NAME
{
public string svcname; /* name of service */
public string svcmgrname; /* name of service manager */
} ;
public struct CTA_SERVICE_ADDR
{
public string addr;
public uint host;
public uint reserved;
};
[ StructLayout( LayoutKind.Sequential )]
public struct CTA_SERVICE_ARGS
{
public string strarg ;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=10 )]
public uint [] args ;
} ;
public struct CTA_MVIP_ADDR
{
public uint board;
public uint bus;
public uint stream;
public uint timeslot;
public uint mode;
} ;public CTA_SERVICE_DESC [] services = new CTA_SERVICE_DESC [4];
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货