C#引用C++函数指针参数的问题
C++函数原型
int WINAPI SMGP30_GetDeliverSM(int Ntimeout,SMGP30_DeliverResp *PdeliverResp);
其中
struct SMGP30_DeliverResp
{
char MsgID[20 + 1];
unsigned char uMsgFormat;
char SrcTermID[SMGP_ADDRS_LEN + 1];
unsigned char uIsReport;
unsigned char uMsgLength;
char MsgContent[MAX_SMGP_MSG_LEN + 1];
char DestTermID[SMGP_ADDRS_LEN +1];
char RecvTime[SMGP_RECVTIME_LEN + 1];
unsigned long uTLVMask;
unsigned char uTP_pid;
unsigned char uTP_udhi;
char LinkID[SMGP30_LINKID_LEN + 1];
unsigned char uSubmitMsgType;
unsigned char uSPDealResult;
unsigned char uSrcTermType;
char SrcTermPseudo[SMGP30_PESUDO_LEN + 1];
char Reserved[SMGP30_RESERVED_LEN + 1];
};
请问转换成C#外部函数引用,如下所示,是否准确?
int WINAPI SMGP30_GetDeliverSM(int Ntimeout,SMGP30_DeliverResp *PdeliverResp);
其中
struct SMGP30_DeliverResp
{
char MsgID[20 + 1];
unsigned char uMsgFormat;
char SrcTermID[SMGP_ADDRS_LEN + 1];
unsigned char uIsReport;
unsigned char uMsgLength;
char MsgContent[MAX_SMGP_MSG_LEN + 1];
char DestTermID[SMGP_ADDRS_LEN +1];
char RecvTime[SMGP_RECVTIME_LEN + 1];
unsigned long uTLVMask;
unsigned char uTP_pid;
unsigned char uTP_udhi;
char LinkID[SMGP30_LINKID_LEN + 1];
unsigned char uSubmitMsgType;
unsigned char uSPDealResult;
unsigned char uSrcTermType;
char SrcTermPseudo[SMGP30_PESUDO_LEN + 1];
char Reserved[SMGP30_RESERVED_LEN + 1];
};
请问转换成C#外部函数引用,如下所示,是否准确?
[DllImport("SMEIDll.dll", EntryPoint = "SMGP30_GetDeliverSM")]
protected static extern int SMGP30_GetDeliverSM(int Ntimeout, out string MsgID, out string uMsgFormat, out byte uIsReport, out byte uMsgLength
, out string MsgContent, out string DestTermID, out string RecvTime, out long uTLVMask, out string uTP_pid, out string uTP_udhi
, out string LinkID, out string uSubmitMsgType, out string uSPDealResult, out string uSrcTermType, out string SrcTermPseudo
, out string Reserved)
...全文
相关推荐
c++面试题面试宝典
c++ 面试题,强烈推荐.构造函数可以被重载,析构函数不能被重载。构造函数在对象被实例化时,根据参数的不同来确定构造函数的选择,但是对析构函数,类对象在声明期结束时自动被系统调用,系统无法判断析构函数的选择,所以析构函数没有重载。
C#委托与C++回调函数处理
告诉你怎么用C#委托处理dll中的回调函数。有几篇文档在里面
C# 调用 C++ 动态库并调用自身注册到动态库的函数
C# 调用 C++ 动态库,并调用c#自身注册到动态库的函数。此项目的编程环境为VS2017.
关于c#调用C++代码的一些应用的体会
1.dll函数的导入: 关键字:unmanaged code ; managed code; 具体应用类:System.Runtime.InteropServices 具体使用方法: [DllImport("muParser.dll", EntryPoint = "mupSetExpr", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern voi
C++与C#的一些比较
C++与C#的一些比较,适合学习者。为您提供这两种语言的最重要差异。


