100分在线等,C#调用C++函数问题
C++调用如下所示
UCHAR __stdcall PacketACK(_MSG_PARA MSG, UCHAR SendBuf[], WORD * SendLen, char ErrMsg[]);
我尝试过
[DllImport("xxcomm.dll", EntryPoint = "PacketACK")]
private static extern byte packetACK(MsgParaACK pMsg, byte[] sendBuf,ref ushort sendLen, StringBuilder errMsg);
internal sealed class DefineConstants
{
public const short MaxCmdLen = 239;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct MsgParaACK
{
public byte DevType; //终端类型
public ushort DevID; //终端ID
public byte AlgoType; //算法标识
//[MarshalAs(UnmanagedType.ByValArray, SizeConst = DefineConstants.MaxCmdLen)]
public byte[] Para ; //参数
}
都不成功。