下面是用 c++ 编写的一段代码,我如何在 c# 中转换它。如果您检查 pams_get_msgw 函数,第一个参数是 (char*),我如何在 c# 中传递相同的参数。
struct
{
short m_nStatus;
short m_nReg_Id;
short m_nNumber_Reg;
} oRegReply;
short nBufSize = sizeof(oRegReply);
q_address oSenderQueue;
nMsgType = MSG_TYPE_SBS_REG_REPLY;
cPriority = 0;
lTimeout = 300; // 30 seconds
//Wait for reply telegram from SBS server
lStatus = pams_get_msgw((char *) &oRegReply, &cPriority, &oSenderQueue,
&nMsgClass, &nMsgType, &nBufSize, &nMsgLen,
&lTimeout, NULL, NULL, NULL, NULL,
NULL, NULL, NULL);
我对pams_get_msgw函数的c# 声明是这样的
[DllImport("DmqCl32.dll")]
public static extern int pams_get_msgw(StringBuilder msg_area, string priority, out q_address source,
out short clas, out short type,
ref short msg_area_len, out short len_data, ref int timeout,
ref int sel_filter, out PSB psb, out ShowBuffer show_buffer,
ref int show_buffer_len, ref int large_area_len, out int large_size,
[MarshalAs(UnmanagedType.LPStr)] string nullarg_3);
和实际的 c++ 声明
typedef long (CALLBACK* PAMSGETMSGW)(char *,char *,q_address *, short *, short *, short *,
short *, long *, long *, struct PSB *,
struct show_buffer *, long *, char *, char *, char * );
我如何将结构传递给第一个参数,就像在 c++ 中所做的那样?