开发小灵退短信,采用中兴的SMGP API ,但在发送一条短消息后取不回MsgID,函数原型如下:
/********************************************************************
FunctionName: SMGPSendSingle 
DESCRIPTION:    Send a short message to single user,if succeed, message
id is filled in sMsgID.if fail, error code is filled in 
nErrorCode.  
Input: nNeedReply:Need reply the status?0:no,1:yes
nMsgLevel:Message level:0:the lowest, 1:normal,
2:above normal 3:the highest
sServiceID:Server type
nMsgFormat:Message format
sFeeType:Fee type
sFeeCode:Fee code
sValidTime:Valid time,format following smpp3.3
sAtTime:The time of sending,format following smpp3.3
sChargeTermID:Paying User number
sDestTermID:Reveive Message number
sReplyPath:User reply number
nMsgLen:Message length
sMsgContent:Message Content

Output: sMsgID:If succeed, message id is filled in sMsgID
nErrorCode:If fail, error code is filled in nErrorCode
Return: 0=OK, 1=fail
History:                                                        
Date        Version Modifier   Activies*******************************************************************/
SMGPAPI_EXPORTS SMGPSendSingle( const int nNeedReply, const int nMsgLevel,
const char *sServiceID, const int nMsgFormat,
const char *sFeeType, const char *sFeeCode, const char *sFixedFee,
const char *sValidTime, const char *sAtTime,
const char *sChargeTermID, const char *sDestTermID,
const char *sReplyPath, const int nMsgLen,
const char *sMsgContent,char *sMsgID, 
int *nErrorCode,const int nMsgType);
我在C#这样定义:
[DllImport("SmGwAPI.dll")]
//发送单条
//public static extern int SMGPSendSingle(int nNeedReply,int nMsgLevel,ref string sServiceID,int nMsgFormat,ref string sFeeType,
// ref string sFeeCode,ref string sFixedFee,ref string sValidTime,ref string sAtTime,ref string sChargeTermID,ref string sDestTermID,
// ref string sReplyPath,int nMsgLen,ref string sMsgContent,ref string sMsgID,ref int nErrorCode,ref int nMsgType) ;
public static extern int SMGPSendSingle(int nNeedReply,int nMsgLevel,string sServiceID,int nMsgFormat,string sFeeType,
string sFeeCode,string sFixedFee,string sValidTime,string sAtTime,string sChargeTermID,string sDestTermID,
string sReplyPath,int nMsgLen,string sMsgContent, ref string sMsgID,ref int nErrorCode,int nMsgType) ;短消息发送成功了,根据它API的说明, Send a short message to single user,if succeed, message id is filled in sMsgID 那么要sMsgId应该有他的值,我用ref 取他回传的的sMsgID C#报未将对像引用到对像的实例的错,直接定义的string ,返回值也无变化!