用delphi编写小灵通短信---希望高手来指定指定 ( 积分: 100 )

  • 主题发起人 主题发起人 kaga
  • 开始时间 开始时间
K

kaga

Unregistered / Unconfirmed
GUEST, unregistred user!
现在网上小灵通短信发送接收程序都是用C/C++或是JAVA写的,就看不到用Delphi写的,前阵子承蒙lichenbin,vvyan等富翁帮助,写了一点小片断,虽然解决了发送和接收的问题,但总是不稳定,经常会出现异常情况。因此,希望有能力的开发人员能够多加指点。<br>本人将前阵子写的程序附上,希望各位富翁能够大力帮助,谢谢!<br> &nbsp; &nbsp;考虑到各富翁不一定有环境测试,请跟我联系,对于能够为大家作出贡献的富翁,请提前预约,本人将尽可能地提供调试环境(宽带自装哦^_^)。<br>我的QQ: 79451849 请注明:小灵通短信调试。
 
现在网上小灵通短信发送接收程序都是用C/C++或是JAVA写的,就看不到用Delphi写的,前阵子承蒙lichenbin,vvyan等富翁帮助,写了一点小片断,虽然解决了发送和接收的问题,但总是不稳定,经常会出现异常情况。因此,希望有能力的开发人员能够多加指点。<br>本人将前阵子写的程序附上,希望各位富翁能够大力帮助,谢谢!<br> &nbsp; &nbsp;考虑到各富翁不一定有环境测试,请跟我联系,对于能够为大家作出贡献的富翁,请提前预约,本人将尽可能地提供调试环境(宽带自装哦^_^)。<br>我的QQ: 79451849 请注明:小灵通短信调试。
 
-----------------------------------------------<br>{<br> uSMGWAPI.PAS 该文件主要将DLL的函数导入进来,<br> 另外,还定义了一些结构供调用,如有不妥,或有更好的方式,敬请各位修改指正,谢谢!<br>}<br>unit uSMGWAPI;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls, ComCtrls, Buttons,<br> &nbsp;ExtCtrls,IniFiles;<br><br>type<br> &nbsp;//---- 接收短信结构 ----------------------<br> &nbsp;PDeliverResp=^TDeliverResp;<br> &nbsp;TDeliverResp= packed record<br> &nbsp; &nbsp; sMsgID : PChar;<br> &nbsp; &nbsp; nIsReport : Integer;<br> &nbsp; &nbsp; nMsgFormat : Integer;<br> &nbsp; &nbsp; sRecvTime : PChar;<br> &nbsp; &nbsp; sSrcTermID : PChar;<br> &nbsp; &nbsp; sDestTermID : PChar;<br> &nbsp; &nbsp; nMsgLen : Integer;<br> &nbsp; &nbsp; sMsgContent : PChar;<br> &nbsp;end;<br><br> &nbsp;//---- 群发短信结构 ------------------------<br> &nbsp;pSendBatchResp = ^TSendBatchResp;<br> &nbsp;TSendBatchResp = packed record<br> &nbsp; &nbsp; &nbsp;sMsgID : PChar;<br> &nbsp; &nbsp; &nbsp;nErrorCode : Integer;<br> &nbsp; &nbsp; &nbsp;sPhoneNo : PChar;<br> &nbsp;end;<br> &nbsp;//------------------------------------------
 
function InitSMGPAPI(P:PChar):integer;stdcall;external 'SMGWAPI.dll';<br> &nbsp;function SMGPDeliver(const nTimeout : Integer; out DeliverResp : TDeliverResp):Integer;stdcall;external 'SMGWAPI.DLL';<br><br> &nbsp;function SMGPSendSingle(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const nNeedReply : integer; &nbsp;//是否要求返回状态报告(0=不要求,1=要求)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const nMsgLevel : integer; &nbsp; &nbsp;//优先级别,(0-3,0表示最低优先级)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const &nbsp;sServiceID : PChar; //业务类型<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const nMsgFormat : Integer; //短消息格式(参照附录短消息格式表)网关不做判定, 透明传输<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const sFeeType : pchar; //资费类别,参照附录短消息参数表<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const &nbsp;sFeeCode : pchar; //资费代码(以分为单位)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const &nbsp;sFixedFee : pchar; //包月费/封顶费(以分为单位)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const &nbsp;sValidTime : pchar; //存活有效期,格式遵循SMPP3.3协议<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const &nbsp;sAtTime : pchar; //定时发送时间,格式遵循SMPP3.3协议<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const &nbsp;sChargeTermID : PChar; //计费号码<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sDestTermID : PChar; //短消息接收号码<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const sReplyPath : PChar; &nbsp;//用户回复号码--新增<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nMsgLen : Integer; //消息长度<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const sMsgContent : PChar; //短消息内容(nMsgLen=0时表示存放短消息的文件名)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sMsgID : PChar; //返回的短消息标识<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var nErrorCode : Integer; //错误代码(参照附录错误代码表)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const nMsgType : Integer //短消息类型,参照附录短消息参数表<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//sSrcTermID : PChar //短消息发送号码。新版API已经删除<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;):Integer;stdcall;external 'SMGWAPI.dll';
 
function SMGPSendBatch( <br>nNeedReply : Integer;<br>nMsgLevel : Integer;<br>sServiceID : PChar;<br>nMsgFormat : Integer;<br>sFeeType : PChar;<br>sFeeCode : PChar;<br>sFixedFee : PChar;<br>sValidTime : PChar;<br>sAtTime : PChar;<br>sChargeTermID : PChar; &nbsp;//计费号码,填空<br>sDestTermIDFile : PChar; // 保存用于接收消息目的号码的文件<br>sReplyPath : PChar; &nbsp; &nbsp;//用户回复号码<br>nMsgLen : Integer;<br>sMsgFile : PChar;<br>sMsgIDFile : PChar; &nbsp;// 保存短消息标识或者错误代码的文件<br>nMsgType : Integer<br>) : Integer; stdcall; external 'SMGWAPI.DLL';
 
//function CMPPActiveTest(dwRetry:word) &nbsp; :integer;stdcall;external 'SMGWAPI.dll';<br> &nbsp;function GetSendBatchResp(sMsgIDFile : PChar;nPos : Integer;SendBatchResp : PSendBatchResp):Integer;stdcall;external 'SMGWAPI.DLL';<br> &nbsp;<br> &nbsp;function SMGPDisconnect &nbsp; &nbsp;:integer;stdcall;external 'SMGWAPI.dll';<br><br>implementation<br><br>end.
 
{<br>单条群发程序,采用多线程编程方式,但在实际测试中,感觉不是很好,一旦执行后,程序界面基本上还是不能动,另外,一旦最小化后,再复原,则会在屏幕中空白一段时间,不知道那位大侠有办法解决;不要让他独占CPU<br>文件名: uThrSendMsg.pas<br>}<br>unit uThrSendMsg;<br><br>interface<br>uses<br> &nbsp;Classes,ADOINT,ADODB,ActiveX,SysUtils,StrUtils,Forms;<br>type<br> &nbsp; TThrSendMsg = Class(TThread)<br> &nbsp; private<br> &nbsp; &nbsp; FCur : Integer;<br> &nbsp; &nbsp; FCodeList : TStrings;<br> &nbsp; &nbsp; FErrorList : TStrings;<br> &nbsp; &nbsp; FCount : Integer;<br><br> &nbsp; &nbsp; FMsgContent : String;<br> &nbsp; &nbsp; FDestTermID : String;<br> &nbsp; &nbsp; FFilename : String;<br> &nbsp; &nbsp; FReplyPath : String;<br> &nbsp; &nbsp; procedure SendMessage;<br> &nbsp; &nbsp; procedure UpdateCaption;<br><br> &nbsp; protected<br> &nbsp; &nbsp; procedure Execute;override;<br> &nbsp; public<br> &nbsp; &nbsp; constructor Create(sFilename : String; strMsgContent:String; strReplyPath : String);overload;<br> &nbsp; &nbsp; destructor Destroy;override;<br> &nbsp; end;<br><br>implementation<br>uses<br> &nbsp; uMsgServer,uSMGWAPI;<br><br>{ TThrSendMsg }
 
constructor TThrSendMsg.Create(sFilename : String; strMsgContent:String; strReplyPath : String);<br>begin<br> &nbsp;//当前处理的序号<br> &nbsp;FCur := 0;<br> &nbsp;FFilename := sFilename;<br> &nbsp;sFilename := sFilename +'.txt';<br> &nbsp;FCodeList := TStringList.Create;<br> &nbsp;FErrorList := TStringList.Create;<br> &nbsp;<br> &nbsp;FCodeList.LoadFromFile(sFilename);<br><br> &nbsp;FReplyPath := strReplyPath;<br> &nbsp;FMsgContent := strMsgContent;<br> &nbsp;FreeOnTerminate := True;<br> &nbsp;inherited Create(False);<br><br><br>end;
 
destructor TThrSendMsg.Destroy;<br>begin<br> &nbsp;SynChronize(UpdateCaption); &nbsp;<br> &nbsp;FCodeList.Free;<br> &nbsp;inherited;<br>end;<br><br>procedure TThrSendMsg.Execute;<br>var<br> &nbsp;i : Integer;<br>begin<br> &nbsp;FCount := FCodeList.Count;<br> &nbsp;While (FCur&lt; FCount) do<br> &nbsp;begin<br> &nbsp; &nbsp; if not Terminated then<br> &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp;Application.ProcessMessages;<br> &nbsp; &nbsp; &nbsp; &nbsp;FDestTermID := FCodeList.Strings[FCur];<br> &nbsp; &nbsp; &nbsp; &nbsp;Synchronize(sendmessage);<br> &nbsp; &nbsp; end;<br> &nbsp; &nbsp; Inc(FCur);<br> &nbsp; &nbsp; if FErrorList.Count &gt;=100 then<br> &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; for i := 0 &nbsp;to 99 &nbsp;do<br> &nbsp; &nbsp; &nbsp; &nbsp; FCodeList.Add(FErrorList.strings);<br> &nbsp; &nbsp; &nbsp; FCount := FCount + 100;<br> &nbsp; &nbsp; &nbsp; FErrorList.Clear;<br> &nbsp; &nbsp; end;<br> &nbsp; &nbsp; sleep(20);<br> &nbsp;end;<br>end;
 
procedure TThrSendMsg.SendMessage;<br>var<br> &nbsp; &nbsp; nNeedReply : Integer;<br> &nbsp; &nbsp; nMsgLevel : Integer;<br> &nbsp; &nbsp; sServiceID : PChar;<br> &nbsp; &nbsp; nMsgFormat : Integer;<br> &nbsp; &nbsp; sFeeCode : PChar;<br> &nbsp; &nbsp; sFeeType : PChar;<br> &nbsp; &nbsp; sFixedFee : PChar;<br> &nbsp; &nbsp; sValidTime : PChar;<br> &nbsp; &nbsp; sAtTime : PChar;<br> &nbsp; &nbsp; sChargeTermID : PChar;<br> &nbsp; &nbsp; sDestTermID : PChar;<br> &nbsp; &nbsp; sReplyPath : PChar;<br> &nbsp; &nbsp; nMsgLen : Integer;<br> &nbsp; &nbsp; sMsgContent : PChar;<br> &nbsp; &nbsp; sMsgID : PChar;<br> &nbsp; &nbsp; nErrorCode : Integer;<br> &nbsp; &nbsp; nMsgType : Integer;<br>begin<br> &nbsp; &nbsp; nNeedReply := 0;//不要求返回状态报告<br> &nbsp; &nbsp; nMsgLevel := 3;<br> &nbsp; &nbsp; sServiceID := PChar('HELP');<br> &nbsp; &nbsp; nMsgFormat := 15;<br> &nbsp; &nbsp; sFeeCode := PChar('');<br> &nbsp; &nbsp; sFeeType := PChar('');<br> &nbsp; &nbsp; sFixedFee := PChar('');<br> &nbsp; &nbsp; sValidTime := PChar('');<br> &nbsp; &nbsp; sAtTime := PChar('');<br> &nbsp; &nbsp; sChargeTermID := PChar('0571123456789');<br> &nbsp; &nbsp; //对方号码需要临时输入<br> &nbsp; &nbsp; sDestTermID := PChar(FDestTermID);<br> &nbsp; &nbsp; sReplyPath := PChar('1186565'); &nbsp; &nbsp; <br> &nbsp; &nbsp; //输入值<br> &nbsp; &nbsp; nMsgLen := Length(PChar(FMsgContent));<br> &nbsp; &nbsp; sMsgContent := PChar(FMsgContent);<br><br> &nbsp; &nbsp; GetMem(sMsgID,11);<br> &nbsp; &nbsp; nErrorCode := 0;<br> &nbsp; &nbsp; nMsgType := 3;<br> &nbsp; &nbsp; try<br> &nbsp; &nbsp; &nbsp; if uSMGWAPI.SMGPSendSingle(nNeedReply,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nMsgLevel,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sServiceID,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nMsgFormat,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sFeeType,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sFeeCode,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sFixedFee,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sValidTime,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sAtTime,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sChargeTermID,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sDestTermID,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sReplyPath,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nMsgLen,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sMsgContent,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sMsgID,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nErrorCode,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nMsgType<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;) = 0 then<br> &nbsp; &nbsp; &nbsp; &nbsp; frmServer.memLog.Lines.Add(sDestTermID +':OK &nbsp;; sMsgID 为【 '+ <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sMsgID +' 】 ;nErrorCode 为【'+IntToStr(nErrorCode) +' 】')<br> &nbsp; &nbsp; &nbsp; else begin<br> &nbsp; &nbsp; &nbsp; &nbsp; //插入error.Log<br> &nbsp; &nbsp; &nbsp; &nbsp; frmServer.memLog.Lines.Add(sDestTermID +':Fail; sMsgID 为【 '+ <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sMsgID +' 】 ;nErrorCode 为【'+<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IntToStr(nErrorCode) +' 】'); &nbsp; &nbsp; &nbsp; &nbsp; <br> &nbsp; &nbsp; &nbsp; &nbsp; FErrorList.Add(sDestTermID);<br> &nbsp; &nbsp; &nbsp; end; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; except on E : Exception do<br> &nbsp; &nbsp; &nbsp; &nbsp;frmServer.memLog.Lines.Add('Error : &nbsp;'+ e.message);<br> &nbsp; &nbsp; end;<br>end;
 
procedure TThrSendMsg.UpdateCaption;<br>begin<br> &nbsp;frmServer.memLog.Lines.Add('已经全部发送完毕:'+ DateTimeToStr(now));<br> &nbsp;frmServer.memLog.Lines.SaveToFile('Send_'+FFilename+'.Log');<br>end;<br><br>end.
 
主界面程序中:<br>// 初始化<br>procedure TfrmServer.ActInitExecute(Sender: TObject);<br>var<br> &nbsp;iniFile : String;<br>begin<br> &nbsp;iniFile := './smgpc.ini';<br> &nbsp;if uSMGWAPI.InitSMGPAPI(PChar(iniFile))= 0 then<br> &nbsp; &nbsp;memLog.Lines.Add('初始化成功')<br> &nbsp;else<br> &nbsp; &nbsp;memLog.lines.Add('初始化失败'); &nbsp; &nbsp;<br><br> &nbsp;_Stop := False;<br> &nbsp;<br>end;<br><br>//线程群发按钮动作<br>procedure TfrmServer.btnThreadSendClick(Sender: TObject);<br>var<br> &nbsp;//SendMsg : TThrSendMsg;<br> &nbsp;//ErrorList : TStrings;<br> &nbsp;strMsgContent,sFilename : String;<br>begin<br> &nbsp;strMsgContent := Trim(mem_msg.Lines.Text);<br> &nbsp;//----------------------------------------<br> &nbsp;sFilename := cboArea.Items.Strings[cboArea.ItemIndex]; &nbsp;<br> &nbsp;memLog.Lines.Add('开始群发:'+DateTimetoStr(now)); &nbsp;<br> &nbsp;// SendMsg 定义为 SendMsg : TThrSendMsg;<br> &nbsp;SendMsg := TThrSendMsg.Create(sFilename,strMsgContent,strReply); &nbsp; &nbsp;<br><br>end;
 
接收程序还没有写好,希望富翁能够用线程来接收,尽量不要影响界面动作。
 
我这里还有有 动态链接库和配置文件,还有开发的文档说明,如果大家有需要的话,可以发邮件给我:e-bus@126.com &nbsp;注明:小灵通短信程序
 
偶要一份:sadero@163.com<br>谢谢
 
单条群发程序,采用多线程编程方式,但在实际测试中,感觉不是很好,一旦执行后,程序界面基本上还是不能动,另外,一旦最小化后,再复原,则会在屏幕中空白一段时间,不知道那位大侠有办法解决;不要让他独占CPU<br><br>在线程中适当的地方增加<br>Application.ProcessMessages;可以让主线程响应用户的动作和重画窗口
 
smgpapi.h 文件;<br>-----------------------------------------------------------------<br>/********************************************************************<br>ModuleName: SMGW Client API<br>FileName: smgpapi.h <br>DESCRIPTION: &nbsp; &nbsp;The Function ProtoType And Struct Definition Of API &nbsp; &nbsp; &nbsp; <br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br>2002/02/27 1.0 Zhang Jiebin &nbsp; &nbsp; &nbsp; &nbsp;Create<br>2002/10/18 3.5 Li Jianfu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Modify<br>********************************************************************/<br>#ifndef _SMGP_API_H_<br>#define _SMGP_API_H_<br><br>/*#define SMGP_CLIENT_VERSION10*/<br>#ifdef SMGP_API_EXPORTS<br>#define SMGPAPI_EXPORTS int __stdcall<br>#else<br>#define SMGPAPI_EXPORTS int <br>#endif<br><br><br>#ifdef _WIN32<br> &nbsp;#pragma pack(push,1)<br>#elif defined _AIX<br> &nbsp;#pragma options align=packed<br>#elif defined _HPUX<br> &nbsp;#pragma pack 1<br>#else<br> &nbsp;#pragma pack (1)<br>#endif<br><br><br>/* Send Batch Message Responce Which Is Written In File */<br>typedef struct<br>{<br> char sMsgID[10+1]; <br> int nErrorCode;<br> char sPhoneNo[21+1];<br>}SendBatchResp;<br><br>/* Query Message Responce Struct */<br>typedef struct<br>{<br> int nMT_TLMsg;<br> int nMT_TLusr;<br> int nMT_Scs;<br> int nMT_WT;<br> int nMT_FL;<br> int nMO_Scs;<br> int nMO_WT;<br> int nMO_FL;<br>}QueryResp;<br><br>/* Receive Message Responce Struct */<br>#ifdef SMGP_API_EXPORTS<br>/*DLL VERSION*/<br>typedef struct<br>{<br> unsigned int nIsReport;<br> unsigned int nMsgFormat;<br> unsigned int nMsgLength;<br> char sMsgID[10+1];<br> char sRecvTime[14+1];<br> char sSrcTermID[21+1];<br> char sDestTermID[21+1];<br> char sMsgContent[252+1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp;sReserve[8+1];<br>}DeliverResp;<br><br>typedef struct<br>{<br> unsigned int nSerialNo; /*消息头中的流水号*/<br> unsigned int nStatus;<br> unsigned int nMsgType;<br> &nbsp; &nbsp;unsigned int nMsgFormat;<br> unsigned int nDesMode;<br> unsigned int nKeySerialNo; <br> unsigned int nIIType;<br> unsigned int nMsgLength;<br> char sMsgID[20+1]; <br> char sSrcTermID[21+1];<br> char sDestTermID[21+1];<br> &nbsp; &nbsp;char sSessionID[20+1];<br> &nbsp; &nbsp;char sServiceID[10+1];<br> char sCpID[8+1];<br> char &nbsp; &nbsp; &nbsp; &nbsp;sTermID[9+1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp;sICCardID[15+1];<br> char sMsgContent[254+1];<br>}TransactionRecv;<br><br>#else<br>/*NOT DLL VERSION*/<br>typedef struct<br>{<br> char sMsgID[10+1];<br> unsigned int nIsReport;<br> unsigned int nMsgFormat;<br> char sRecvTime[14+1];<br> char sSrcTermID[21+1];<br> char sDestTermID[21+1];<br> unsigned int nMsgLength;<br> char sMsgContent[252+1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp;sReserve[8+1];<br>}DeliverResp;<br><br>typedef struct<br>{<br> unsigned int nSerialNo; /*消息头中的流水号*/<br> unsigned int nStatus;<br> char sMsgID[20+1]; <br> unsigned int nMsgType;<br> &nbsp; &nbsp;unsigned int nMsgFormat;<br> char sSrcTermID[21+1];<br> &nbsp; &nbsp;char sDestTermID[21+1];<br> &nbsp; &nbsp;char sSessionID[20+1];<br> &nbsp; &nbsp;char sServiceID[10+1];<br> char sCpID[8+1];<br> unsigned int nDesMode;<br> char &nbsp; &nbsp; &nbsp; &nbsp;sTermID[9+1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp;sICCardID[15+1];<br> unsigned int nKeySerialNo;<br> unsigned int nIIType;<br> unsigned int nMsgLength;<br> char sMsgContent[254+1];<br>}TransactionRecv;<br><br>#endif /*SMGP_API_EXPORTS*/<br><br>#ifdef _WIN32<br> &nbsp;#pragma pack(pop)<br>#elif defined _AIX<br> &nbsp;#pragma options align=reset<br>#elif defined _HPUX<br> &nbsp;#pragma pack 4<br>#else<br> &nbsp;#pragma pack ()<br>#endif<br><br><br>#ifdef __cplusplus <br>extern &quot;C&quot;{<br>#endif<br><br>/********************************************************************<br>The Function Prototype<br>********************************************************************/<br><br>/********************************************************************<br>FunctionName: InitSMGPAPI <br>DESCRIPTION: &nbsp; &nbsp;Must call this initiate function before <br> calling others SMGP API functions if standard c is <br> used, param sINIFile must be specfied. &nbsp; &nbsp; &nbsp; <br>Input: sINIFile:The address of init file name <br>Output: None<br>Return: 0=OK, 1=fail<br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br><br>*******************************************************************/<br>SMGPAPI_EXPORTS InitSMGPAPI(const char *sINIFile);<br><br><br>/********************************************************************<br>FunctionName: SMGPSendSingle <br>DESCRIPTION: &nbsp; &nbsp;Send a short message to single user,if succeed, message<br> id is filled in sMsgID.if fail, error code is filled in <br> nErrorCode. &nbsp;<br>Input: nNeedReply:Need reply the status?0:no,1:yes<br> nMsgLevel:Message level:0:the lowest, 1:normal,<br> 2:above normal 3:the highest<br> sServiceID:Server type<br> nMsgFormat:Message format<br> sFeeType:Fee type<br> sFeeCode:Fee code<br> sValidTime:Valid time,format following smpp3.3<br> sAtTime:The time of sending,format following smpp3.3<br> sChargeTermID:Paying User number<br> sDestTermID:Reveive Message number<br> sReplyPath:User reply number<br> nMsgLen:Message length<br> sMsgContent:Message Content<br> <br>Output: sMsgID:If succeed, message id is filled in sMsgID<br> nErrorCode:If fail, error code is filled in nErrorCode<br>Return: 0=OK, 1=fail<br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br><br>*******************************************************************/<br>SMGPAPI_EXPORTS SMGPSendSingle( const int nNeedReply, const int nMsgLevel,<br> const char *sServiceID, const int nMsgFormat,<br> const char *sFeeType, const char *sFeeCode, const char *sFixedFee,<br> const char *sValidTime, const char *sAtTime,<br> const char *sChargeTermID, const char *sDestTermID,<br> const char *sReplyPath, const int nMsgLen,<br> const char *sMsgContent,char *sMsgID, <br> int *nErrorCode,const int nMsgType,const char *sReserve);<br><br><br>/********************************************************************<br>FunctionName: SMGPSendBatch <br>DESCRIPTION: &nbsp; &nbsp;Send a short message to multiple users,if succeed, message<br> id is filled in sMsgID.if fail, error code is filled in <br> nErrorCode.<br> &nbsp; If nMsgLen is 0, then sMsgFile is the filename which contains <br> &nbsp; message content, if not, then sMsgFile contains the message. <br> &nbsp; If Both of them are 0, SMGPSendBatch fail.<br><br>Input: nNeedReply:Need reply the status?0:no,1:yes<br> nMsgLevel:Message level:0:the lowest, 1:normal,<br> 2:above normal 3:the highest<br> sServiceID:Server type<br> nMsgFormat:Message format<br> sFeeType:Fee type<br> sFeeCode:Fee code<br> sValidTime:Valid time,format following smpp3.3<br> sAtTime:The time of sending,format following smpp3.3<br> sChargeTermID:Paying User number<br> sDestTermID:Reveive Message number<br> sReplyPath:User reply number<br> nMsgLen:Message length<br> sMsgFile:The file which contains the message content or<br> message Content,see description.<br> sMsgIDFile:The file name which save the all message id<br> or error code.<br> <br>Output: None<br>Return: 0=OK, 1=fail<br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br><br>*******************************************************************/<br>SMGPAPI_EXPORTS SMGPSendBatch( const int nNeedReply, const int nMsgLevel,<br> const char *sServiceID, const int nMsgFormat,<br> const char *sFeeType, const char *sFeeCode,const char *sFixedFee,<br> const char *sValidTime, const char *sAtTime,<br> const char *sChargeTermID, const char *sDestTermIDFile,<br> const char *sReplyPath, const int nMsgLen,<br> const char *sMsgFile, const char *sMsgIDFile,const int nMsgType,const char *sReserve);<br><br>/********************************************************************<br>FunctionName: GetSendBatchResp <br>DESCRIPTION: &nbsp; &nbsp;Give a MSGID file which is created by Batch send, &nbsp;<br> specify position of the record, then get response from <br> the file. each field of the param SendBatchResp will<br> filled. nPos start from 0<br>Input: sMsgIDFile:The file name which save the all message id<br> or error code.<br> <br>Output: pSendBatchResp:The message id and error code<br>Return: 0=OK, 1=fail<br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br><br>*******************************************************************/<br>SMGPAPI_EXPORTS GetSendBatchResp(char *sMsgIDFile, int nPos, SendBatchResp *pSendBatchResp);<br><br>/********************************************************************<br>FunctionName: SMGPDeliver <br>DESCRIPTION: &nbsp; &nbsp;Get ShortMessage from SMGW<br>Input: nTimeout:how many seconds the function keep waiting short<br> message, 0 means wait forever. <br>Output: pDeliverResp:the delivered short message is filled in pDeliverResp<br>Return: 0=OK, 1=fail<br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br><br>*******************************************************************/<br>SMGPAPI_EXPORTS SMGPDeliver(const int nTimeoutIn, DeliverResp *pDeliverResp);<br><br>/********************************************************************<br>FunctionName: CMMPActiveTest <br>DESCRIPTION: &nbsp; &nbsp;See if the SMGW is available<br>Input: <br>Output: nErrorCode:Response error code,0 is ok <br>Return: 0=OK, 1=fail<br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br><br>*******************************************************************/<br>SMGPAPI_EXPORTS SMGPActiveTest(int *nErrorCode);<br><br>/********************************************************************<br>FunctionName: SMGPRecvTransaction<br>DESCRIPTION: &nbsp; &nbsp;Get Electric Transation ShortMessage from SMGW<br>Input: nTimeout:how many seconds the function keep waiting short<br> message, 0 means wait forever. <br>Output: pTransactionRecv:the received electric transaction short message is filled in pTransactionRecv<br>Return: 0=OK, 1=fail<br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br><br>*******************************************************************/<br>SMGPAPI_EXPORTS SMGPRecvTransaction(const int nTimeoutIn, TransactionRecv *pTransactionRecv);<br><br>/********************************************************************<br>FunctionName: SMGPSendTransactionResp<br>DESCRIPTION: &nbsp; &nbsp;Support Electric Transaction.<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Send a short message to single user,if succeed, message<br> id is filled in sMsgID.if fail, error code is filled in <br> nErrorCode. &nbsp;<br> <br>Input: nSerialNo,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nStatus,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sMessageID, <br> nMsgType,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nNeedReport,sFeeType,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sFeeCode, sFixedFee,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nMsgFormat, sSrcTermID,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sChargeTermID, sDestTermID,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sSessionID, sServiceID,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sCpID, nDesMode,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nAckDesMode, const char *sTermID,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sICCardID, nKeySerialNo,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nIIType,nMsgLength,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sMsgContent<br> <br>Output: nErrorCode:If fail, error code is filled in nErrorCode<br>Return: 0=OK, 1=fail<br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br><br>*******************************************************************/<br>SMGPAPI_EXPORTS SMGPSendTransactionResp(<br> const int nSerialNo, const int nStatus,<br> const char *sMessageID, const int nMsgType,<br> const int nNeedReport, const char *sFeeType,<br> const char *sFeeCode, const char *sFixedFee,<br> const int nMsgFormat, const char *sSrcTermID,<br> &nbsp; &nbsp;const char *sChargeTermID, const char *sDestTermID,<br> &nbsp; &nbsp;const char *sSessionID, const char *sServiceID,<br> const char *sCpID, const int nDesMode,<br> const int nAckDesMode, const char *sTermID,<br> const char *sICCardID, const int nKeySerialNo,<br> &nbsp; &nbsp;const int nIIType, const int nMsgLength,<br> const char *sMsgContent);<br><br><br>#ifdef __cplusplus<br>}<br>#endif<br><br><br>#endif &nbsp; /* _SMGP_API_H_ */<br><br>-----------------------------------------------------------------
 
smgpdef.h文件<br>----------------------------------------<br>/******************************************************************<br>ModuleName: SMGW Client API<br>FileName: smgpdef.h <br>DESCRIPTION: &nbsp; &nbsp;SMGP Protocol Message Definition &nbsp; &nbsp; &nbsp; <br>History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>Date &nbsp; &nbsp; &nbsp; Version Modifier Activies<br>2002/02/27 1.0 Zhang Jiebin Create<br>2002/10/18 3.5 Li Jianfu &nbsp; Modify<br>********************************************************************/<br>#ifndef _SMGP_DEFINE_H_<br>#define _SMGP_DEFINE_H_<br><br>#ifdef _WIN32<br> &nbsp;#pragma pack(push,1)<br>#elif defined _AIX<br> &nbsp;#pragma options align=packed<br>#elif defined _HPUX<br> &nbsp;#pragma pack 1<br>#else<br> &nbsp;#pragma pack (1)<br>#endif<br><br>/********************************************************************<br>The Macro Definition<br>********************************************************************/<br>/* The SMGW Client Version */<br>#define SMGP_CLIENT_VERSION 0x13<br><br>/*#define SMGP_CLIENT_VERSION10_OK*/<br><br>/* The Maximal Length Of Short Message */<br>#define MAX_SM_LEN 252<br>#define MAX_SM_CUT_NUM 100<br><br>/* The Maximal Length Of Electric Transaction Short Message */ &nbsp; <br>#define MAX_ESM_LEN 254<br><br>/*The Maximal number of DestTermID*/<br>#define MAX_DEST_TERM_NUM &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 100<br><br>/* The Short Message Request ID */<br>#define REQUEST_ID_LOGIN 0x00000001<br>#define REQUEST_ID_LOGIN_RESP 0x80000001<br>#define REQUEST_ID_SUBMIT 0x00000002<br>#define REQUEST_ID_SUBMIT_RESP 0x80000002<br>#define REQUEST_ID_DELIVER 0x00000003<br>#define REQUEST_ID_DELIVER_RESP 0x80000003<br>#define REQUEST_ID_ACTIVE_TEST 0x00000004<br>#define REQUEST_ID_ACTIVE_TEST_RESP 0x80000004<br>#define REQUEST_ID_EXIT 0x00000006<br>#define REQUEST_ID_EXIT_RESP 0x80000006<br>#define REQUEST_ID_QUERY 0x00000007<br>#define REQUEST_ID_QUERY_RESP 0x80000007<br>/*Support Electric Transaction*/<br>#define REQUEST_ID_TRANSACTION 0x00000016<br>#define REQUEST_ID_TRANSACTION_RESP 0x80000016<br><br>/* Need Reply Yes Or No */<br>#define NEED_REPLY_YES 1<br>#define NEED_REPLY_NO 0<br><br>#define NEED_REPLY_MAX &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;128<br>#define NEED_REPLY_MIN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br><br>/* Need Report Yes Or No */<br>#define NEED_REPORT_YES 1<br>#define NEED_REPORT_NO 0<br><br>/* nMsgFormat Macro */<br>#define MSG_FORMAT_ASCII 0<br>#define MSG_FORMAT_WRITE_CARD 3<br>#define MSG_FORMAT_BINARY 4<br>#define MSG_FORMAT_UCS2 8<br>#define MSG_FORMAT_GB 15<br>#define MSG_FORMAT_PASSWORD 100 <br><br>/* Fee Type Macro */<br>#define FEE_FREE &quot;0&quot;<br>#define FEE_BY_ITEM &quot;1&quot;<br>#define FEE_BY_MONTH &quot;2&quot;<br>#define FEE_BY_MAXINUM &quot;3&quot;<br><br>/* Login Mode */<br>#define LOGIN_SEND_MODE 0<br>#define LOGIN_RECV_MODE 1<br>#define LOGIN_TRANSMIT_MODE 2<br><br>/* Submit Priority */<br>#define SUBMIT_PRIORITY_LOWEST 0<br>#define SUBMIT_PRIORITY_NORMAL 1<br>#define SUBMIT_PRIORITY_ABOVE_NORMAL 2<br>#define SUBMIT_PRIORITY_HIGHEST 9<br><br>/* Message Status */<br>#define MESSAGE_STATUS_DELIVERED 0<br>#define MESSAGE_STATUS_EXPIRED 1<br>#define MESSAGE_STATUS_DELITED 2<br>#define MESSAGE_STATUS_UNDELIVERABLE 3<br>#define MESSAGE_STATUS_ACCEPTED 4<br>#define MESSAGE_STATUS_UNKNOW 5<br><br>/* SMGP Error Code */<br>#define SMGP_ERROR_CODE_OK 0<br>#define SMGP_ERROR_CODE_INVALIDE_PACKET 1<br>#define SMGP_ERROR_CODE_LOGIN_FAIL 2<br>#define SMGP_ERROR_CODE_INVALID_PRIORITY 3<br>#define SMGP_ERROR_CODE_INVALID_FEETYPE 4 <br>#define SMGP_ERROR_CODE_INVALID_FEECODE 5<br>#define SMGP_ERROR_CODE_INVALID_MSGFORMAT 6<br>#define SMGP_ERROR_CODE_INVALID_VALIDTIME 7<br>#define SMGP_ERROR_CODE_INVALID_ATTIME 8<br>#define SMGP_ERROR_CODE_INVALID_SRCTERMID 9<br>#define SMGP_ERROR_CODE_INVALID_DESTTERMID 10<br>#define SMGP_ERROR_CODE_INVALID_LEN 11<br>#define SMGP_ERROR_CODE_INVALID_DESTSMGW 12<br>#define SMGP_ERROR_CODE_INVALID_DESTSRCSMGW 13<br>#define SMGP_ERROR_CODE_INVALID_FWDDESTTERMID 14<br>#define SMGP_ERROR_CODE_CHANGEPASSWORD_FAIL 15<br>#define SMGP_ERROR_CODE_RESERVERD 16<br><br>/* API Error Code */<br>#define SMGP_API_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 <br>#define SMGP_API_ERROR_MSG_FORMAT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3<br>#define SMGP_API_ERROR_MSG_LENGTH &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4<br>#define SMGP_API_ERROR_MSG_FEECODE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5<br>#define SMGP_API_ERROR_SERVICE_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 7<br>#define SMGP_API_ERROR_SYSTEM_BUSY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;8<br>#define SMGP_API_ERROR_CP_NUMBER &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10<br>#define SMGP_API_ERROR_CONTENT_FORMAT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 11<br>#define SMGP_API_ERROR_FEE_TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 12<br>#define SMGP_API_ERROR_VALID_TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 13<br>#define SMGP_API_ERROR_AT_TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;14<br>#define SMGP_API_ERROR_CHARGE_TERM_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 15<br>#define SMGP_API_ERROR_DEST_TERM_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 16<br>#define SMGP_API_ERROR_DEST_TERM_ID_FILE &nbsp; &nbsp; &nbsp; &nbsp;17<br>#define SMGP_API_ERROR_MSG_FILE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 18<br>#define SMGP_API_ERROR_CONNECT_GW &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 20<br>#define SMGP_API_ERROR_AUTHID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 21<br>#define SMGP_API_ERROR_SEND_QUEUE_OVER &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;23<br>#define SMGP_API_ERROR_COMMAND_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 25<br>#define SMGP_API_ERROR_SEQUENSE_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;26<br>#define SMGP_API_ERROR_VERSION &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;29<br>#define SMGP_API_ERROR_MSG_TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 30<br>#define SMGP_API_ERROR_PRIORITY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 31<br>#define SMGP_API_ERROR_TIME_TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;35<br>#define SMGP_API_ERROR_QUERY_TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 38<br>#define SMGP_API_ERROR_ROUTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;39<br>#define SMGP_API_ERROR_FIXED_FEE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;40<br>#define SMGP_API_ERROR_SRC_TERM_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;46<br>#define SMGP_API_ERROR_SYSTEM &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 99<br><br>/* SMGP Length */<br>#define SMGP_MSG_HEAD_LENGTH (UINT32)(sizeof(SMGP_Head))<br>#define SMGP_LOGIN_MSG_LENGTH (UINT32)(sizeof(SMGP_Login))<br>#define SMGP_SUBMIT_MSG_LENGTH (UINT32)(sizeof(SMGP_Submit))<br>#define SMGP_SUBMIT_BATCH_MSG_LENGTH (UINT32)(sizeof(SMGP_Submit_Batch))<br>#define SMGP_EXIT_MSG_LENGTH (UINT32)(sizeof(SMGP_Head))<br>#define SMGP_DELIVER_RSP_MSG_LENGTH (UINT32)(sizeof(SMGP_DeliverResp))<br>/*Support Electric Transaction*/<br>#define SMGP_TRANSACTION_MSG_LENGTH (UINT32)(sizeof(SMGP_Transaction))<br>#define SMGP_TRANSACTION_RSP_MSG_LENGTH (UINT32)(sizeof(SMGP_TransactionResp))<br><br>/* SMGP Submit Message Type */<br>#define SMGP_SUBMIT_CANCEL_SUBSCRIBE 1<br>#define SMGP_SUBMIT_SUBSCRIBE_REQUEST 2<br>#define SMGP_SUBMIT_REQUEST 3<br>#define SMGP_SUBMIT_SUBSCRIBE 4<br>#define SMGP_SUBMIT_EXCHANGE 5<br>#define SMGP_SUBMIT_QUERY 6<br><br>/********************************************************************<br>The Struct Definition<br>********************************************************************/<br><br>/* SMGP Message Head */<br>typedef struct<br>{<br> unsigned int nPacketLength; /* 4 bytes */<br> unsigned int nRequestId; /* 4 bytes */<br> unsigned int nSequenceId; /* 4 bytes */<br>}SMGP_Head;<br><br>/* SMGP Message Login */<br>typedef struct<br>{ <br> SMGP_Head msgHead; /* 12 bytes */<br> char sUser[8]; /* 11 bytes */<br> char sAuthenMD5[16]; /* 16 bytes */<br> unsigned char nLoginMode; /* 1 bytes */<br> unsigned int nTimeStamp; /* 4 bytes */<br> unsigned char nVersion; /* 1 bytes */<br>}SMGP_Login;<br><br>/* SMGP Message Login Resp*/<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> unsigned int nResult; /* 4 bytes */<br>}SMGP_LoginResp;<br><br>/* SMGP Message Submit*/<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> unsigned char nMsgType; /* 1 bytes */<br> unsigned char nNeedReport; /* 1 bytes */<br> unsigned char nPriority; /* 1 bytes */<br> char sServerId[10]; /* 10 bytes */<br> char sFeeType[2]; /* 2 bytes */<br> char sFeeCode[6]; /* 6 bytes */<br> char sFixedFee[6]; /* 6 bytes */<br> unsigned char nMsgFormat; /* 1 bytes */<br> char sValidTime[17]; /* 17 bytes */<br> char sAtTime[17]; /* 17 bytes */<br> char sReplyPath[21]; /* 21 bytes */<br> char sChargeTermId[21]; /* 21 bytes */<br> unsigned char nDestTermIdCount; /* 1 bytes */<br> char sDestTermId[21]; /* 21 * 100 bytes */<br> unsigned char nMsgLength; /* 1 bytes */<br> char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pReserve[8]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* 8 bytes */<br>}SMGP_Submit;<br><br>/* SMGP Message Submit*/<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> unsigned char nMsgType; /* 1 bytes */<br> unsigned char nNeedReport; /* 1 bytes */<br> unsigned char nPriority; /* 1 bytes */<br> char sServerId[10]; /* 10 bytes */<br> char sFeeType[2]; /* 2 bytes */<br> char sFeeCode[6]; /* 6 bytes */<br> char sFixedFee[6]; /* 6 bytes */<br> unsigned char nMsgFormat; /* 1 bytes */<br> char sValidTime[17]; /* 17 bytes */<br> char sAtTime[17]; /* 17 bytes */<br> char sReplyPath[21]; /* 21 bytes */<br> char sChargeTermId[21]; /* 21 bytes */<br> unsigned char nDestTermIdCount; /* 1 bytes */<br> char sDestTermId[21*MAX_DEST_TERM_NUM]; /* 21 * 100 &nbsp;bytes */<br> unsigned char nMsgLength; /* 1 bytes */<br> char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sReserve[8];<br>}SMGP_Submit_Batch;<br><br>/* SMGP Message Submit Resp*/<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> char sMsgId[10]; /* 10 bytes */<br> unsigned int nResult; /* 4 bytes */<br>}SMGP_SubmitResp;<br><br>/* SMGP Message Deliver*/<br>typedef struct<br>{ <br> SMGP_Head msgHead; /* 12 bytes */<br> char sMsgId[10]; /* 10 bytes */<br> unsigned char nIsReport; /* 1 bytes */<br> unsigned char nMsgFormat; /* 1 bytes */<br> char sRecvTime[14]; /* 14 bytes */<br> char sSrcTermId[21]; /* 21 bytes */<br> char sDestTermId[21]; /* 21 bytes */<br> unsigned char nMsgLength; /* 1 bytes */<br> char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */<br>}SMGP_Deliver;<br><br>/* SMGP Message Deliver Resp*/<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> char sMsgId[10]; /* 10 bytes */<br> unsigned int nResult; /* 4 bytes */<br>}SMGP_DeliverResp;<br><br>/* SMGP Message Active Test*/<br>/* Empty Body */<br><br>/* SMGP Message Active Test Resp */<br>/* Empty Body */<br><br><br>/* SMGP Message Transaction: Support Electric Transaction*/<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> unsigned int nStatus; /* 4 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sMessageID[20]; &nbsp; &nbsp; &nbsp; &nbsp; /* 20 bytes */<br> unsigned char nMsgType; &nbsp; &nbsp;/* 1 bytes */<br> unsigned char nMsgFormat; /* 1 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sSrcTermID[21]; &nbsp; &nbsp; &nbsp; &nbsp; /* 21 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sDestTermID[21]; &nbsp; &nbsp; &nbsp; &nbsp;/* 21 bytes */<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sSessionID[20]; &nbsp; &nbsp; &nbsp; &nbsp; /* 20 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sServiceID[10]; &nbsp; &nbsp; &nbsp; &nbsp; /* 10 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sCpID[8]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 8 bytes */<br> unsigned char &nbsp; nDesMode; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 1 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sTermID[9]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 9 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sICCardID[15]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* 15 bytes */<br> unsigned char &nbsp; nKeySerialNo; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 1 bytes */<br> &nbsp; &nbsp;unsigned char &nbsp; nIIType; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* 1 bytes */<br> unsigned short &nbsp;nMsgLength; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 2 bytes */<br> char sMsgContent[MAX_ESM_LEN]; /* MAX_ESM_LEN bytes */<br>}SMGP_Transaction;<br><br>/* SMGP Message Transaction: Support Electric Transaction*/<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> unsigned int nStatus; /* 4 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sMessageID[20]; &nbsp; &nbsp; &nbsp; &nbsp; /* 20 bytes */<br> unsigned char nMsgType; &nbsp; &nbsp;/* 1 bytes */<br> unsigned char nNeedRport; &nbsp; &nbsp;/* 1 bytes */<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sFeeType[2]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* 2 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sFeeCode[6]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* 6 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sFixedFee[6]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 6 bytes */<br> unsigned char nMsgFormat; /* 1 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sSrcTermID[21]; &nbsp; &nbsp; &nbsp; &nbsp; /* 21 bytes */<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sChargeTermID[21]; &nbsp; &nbsp; &nbsp;/* 21 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sDestTermID[21]; &nbsp; &nbsp; &nbsp; &nbsp;/* 21 bytes */<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sSessionID[20]; &nbsp; &nbsp; &nbsp; &nbsp; /* 20 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sServiceID[10]; &nbsp; &nbsp; &nbsp; &nbsp; /* 10 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sCpID[8]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 8 bytes */<br> unsigned char &nbsp; nDesMode; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 1 bytes */<br> unsigned char &nbsp; nAckDesMode; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* 1 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sTermID[9]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 9 bytes */<br> char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sICCardID[15]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* 15 bytes */<br> unsigned char &nbsp; nKeySerialNo; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 1 bytes */<br> &nbsp; &nbsp;unsigned char &nbsp; nIIType; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* 1 bytes */<br> unsigned short &nbsp;nMsgLength; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* 2 bytes */<br> char sMsgContent[MAX_ESM_LEN]; /* MAX_ESM_LEN bytes */<br>}SMGP_TransactionResp;<br><br>/* SMGP Message Forward*/<br>typedef struct<br>{ <br> SMGP_Head msgHead; /* 12 bytes */<br> char sDestSMGWNo[6]; /* 6 bytes */<br> char sSrcSMGWNo[6]; /* 6 bytes */<br> unsigned char nSMType; /* 1 bytes */<br> unsigned char nNeedReport; /* 1 bytes */<br> unsigned char nPriority; /* 1 bytes */<br> char sMsgSrc[6]; /* 6 bytes */<br> char sServerId[10]; /* 10 bytes */<br> char sFeeType[2]; /* 2 bytes */<br> char sFeeCode[6]; /* 6 bytes */<br> unsigned char nMsgFormat; /* 1 bytes */<br> char sValidTime[17]; /* 17 bytes */<br> char sAtTime[17]; /* 17 bytes */<br> char sReplyPath[21]; /* 21 bytes */<br> char sDestTermId[21]; /* 21 bytes */<br> unsigned char nMsgLength; /* 1 bytes */<br> char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */<br>}SMGP_Forward;<br><br>/* SMGP Message Forward Resp*/<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> char sMsgId[10]; /* 10 bytes */<br> unsigned int nResult; /* 4 bytes */<br>}SMGP_ForwardResp;<br><br>/* SMGP Message Exit*/<br>/* Empty Body */<br><br>/* SMGP Message Exit Resp*/<br>/* Empty Body */<br><br>/* SMGP Message Status Report */<br>typedef struct<br>{<br> SMGP_Head msgHead; /* 12 bytes */<br> char sMsgId[10]; /* 10 bytes */<br> char sSubmitDate[14]; /* 14 bytes */<br> char sDoneDate[14]; /* 14 bytes */<br> char sStatus[7]; /* 7 bytes */<br> char sErr[3]; /* 3 bytes */<br>}SMGP_StatusReport;<br><br>/* SMGP Message Change Passward */<br>typedef struct<br>{<br> char sOldPassward[15]; /* 15 bytes */<br> char sNewPassward[15]; /* 15 bytes */<br>}SMGP_ChangePassward;<br><br><br>/*SMGP MSGID*/<br>typedef struct<br>{<br> &nbsp; &nbsp;char sGwCode[30];<br> char sTime[30];<br> char sSequenceNo[30];<br>}SMGP_MsgID;<br><br>/********************************************************************<br>The Function Definition<br>********************************************************************/<br>int SMGPPackHeadMsg(unsigned int nPacketLength, <br> unsigned int nRequestId, <br> SMGP_Head *pSMGPHead);<br><br><br>int SMGPPackLoginMsg(char nLoginMode,SMGP_Login *pLoginMsg);<br><br>#ifdef SMGP_CLIENT_VERSION10_OK<br>int SMGPPackSubmitMsg( const int nNeedReply, const int nMsgLevel, <br> const char *sServiceID, const int nMsgFormat, <br> const char *sFeeType, const char *sFeeCode, <br> const char *sValidTime, const char *sAtTime, <br> const char *sChargeTermID, const char *sDestTermID,<br> const char *sReplyPath, const int nMsgLen, <br> const char *sMsgContent, const char *sReserve,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SMGP_Submit *pSubmit);<br><br>#else<br>int SMGPPackSubmitMsg( const int nNeedReply, const int nMsgLevel, <br> const char *sServiceID, const int nMsgFormat, <br> const char *sFeeType, const char *sFeeCode, <br> const char *sValidTime, const char *sAtTime, <br> const char *sChargeTermID, const char *sDestTermID,<br> const char *sReplyPath, const int nMsgLen, <br> const char *sMsgContent, const int nMsgType,<br> const char *sFixCode, const char *sReserve,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SMGP_Submit *pSubmit);<br>#endif<br><br>#ifdef SMGP_CLIENT_VERSION10_OK<br>int SMGPPackSubmitBatchMsg( const int nNeedReply, const int nMsgLevel, <br> const char *sServiceID, const int nMsgFormat, <br> const char *sFeeType, const char *sFeeCode, <br> const char *sValidTime, const char *sAtTime, <br> const char *sChargeTermID,<br> const int &nbsp;nDestTermIDCount, &nbsp;const char *sDestTermID, <br> const char *sReplyPath, const int nMsgLen, <br> const char *sMsgContent, const char *sReserve,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SMGP_Submit_Batch *pSubmit);<br><br>#else<br>int SMGPPackSubmitBatchMsg( const int nNeedReply, const int nMsgLevel, <br> const char *sServiceID, const int nMsgFormat, <br> const char *sFeeType, const char *sFeeCode, <br> const char *sValidTime, const char *sAtTime, <br> const char *sChargeTermID, <br> const int &nbsp;nDestTermIDCount, const char &nbsp;*sDestTermID,<br> const char *sReplyPath, const int nMsgLen, <br> const char *sMsgContent, const int nMsgType,<br> const char *sFixCode, const char *sReserve,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SMGP_Submit_Batch *pSubmit);<br>#endif<br><br>int SMGPPackExitMsg(SMGP_Head *pSMGPExit);<br><br>int SMGPPackDeliverRspMsg( SMGP_DeliverResp *pDeliverRsp, <br> unsigned int nSequense, <br> char *sMsgId, <br> unsigned int nResult);<br><br>int SMGPPackActiveTestMsg(SMGP_Head *pActiveTest);<br><br>/*Support Electric Transaction*/<br>int SMGPPackTransactionRespMsg(const int nSerialNo,const int nStatus,<br> const char *sMessageID, const int nMsgType,<br> const int nNeedReport, const char *sFeeType,<br> const char *sFeeCode, const char *sFixedFee,<br> const int nMsgFormat, const char *sSrcTermID,<br> &nbsp; &nbsp;const char *sChargeTermID, const char *sDestTermID,<br> &nbsp; &nbsp;const char *sSessionID, const char *sServiceID,<br> const char *sCpID, const int nDesMode,<br> const int nAckDesMode, const char *sTermID,<br> const char *sICCardID, const int nKeySerialNo,<br> &nbsp; &nbsp;const int nIIType, const int nMsgLength,<br> const char *sMsgContent,SMGP_TransactionResp *pTransResp);<br><br>#ifdef _WIN32<br> &nbsp;#pragma pack(pop)<br>#elif defined _AIX<br> &nbsp;#pragma options align=reset<br>#elif defined _HPUX<br> &nbsp;#pragma pack 4<br>#else<br> &nbsp;#pragma pack ()<br>#endif<br><br><br>#endif /* #define _SMGP_DEFINE_H_ */<br><br><br><br><br>---------------------------------------
 
typedef struct<br>{<br> char sMsgID[10+1];<br> unsigned int nIsReport;<br> unsigned int nMsgFormat;<br> char sRecvTime[14+1];<br> char sSrcTermID[21+1];<br> char sDestTermID[21+1];<br> unsigned int nMsgLength;<br> char sMsgContent[252+1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp;sReserve[8+1];<br>}DeliverResp;<br><br>你的翻译少了最后一项<br>char &nbsp; &nbsp; &nbsp; &nbsp;sReserve[8+1];<br>另外,不要用packed record,直接用record就可以了
 

Similar threads

D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部