c#调用中兴API开发cngpSP端网关
我是做sp的,现在要写小灵通网关,有中兴提供的api 是个dll文件,不知道c#如何包含调用,在引用里添加报错,说不是com或组件,api说明文件中推荐用java c++调用我想能用java调用 ,也应该能用c#调用吧,如果不能调用
现用c#写,不知道底层具体是什么机制,是不是用sokote编程,很急 希望高手指点,有例子更好
里面有如下函数:
api说明如下:
1动态库接口函数调用说明
动态链接库包含smgpapi.dll、smgpapi.lib、smgpapi.h三个文件
使用动态链接库smgpapi.dll,按照如下步骤:
1. 应用程序调用initsmgpapi函数用来注册通讯。
2. 注册成功后,应用程序调用smgpsendlogin函数向网关发送登录消息。另外,应用程序若想终止与外界的通讯,应用程序调用smgpexitmsg函数发送注销登录消息。
3. 应用程序调用smgpsendsingle向一个用户发送submit消息。一般来说,应用程序收到自己所发消息的响应。
4. 应用程序调用smgpsendbatch向多个用户发送submit消息。一般来说,应用程序收到自己所发消息的响应。
5. 应用程序调用smgpdeliver函数接收网关发送来的deliver消息消息。
6. 应用程序调用smgpactivetest函数测试与网关之间的链路。
7. 应用程序调用smgpsendbatchresp函数查询smgpsendbatch函数发出消息的响应。
8. 应用程序调用smgprecvsnreport函数查询发送消息的状态报告。
9. 应用程序在处理完收到的消息后,必须调用closesmgpapi释放内存。
2动态库接口原型函数
1、byte initsmgpapi( char sinifile[], hwnd hwnd, hinstance hinstance );
2、byte smgpsendlogin( char clientid[], char password[], word *pwsenderr, dword *pdwstatus, word *pwrecverr );
3、byte smgpsendsingle( smgpsendsingle_t *ptsmgpsendsingle, word *pwsenderr, word *pwrecverr );
4、byte smgpsendbatch( smgpsendbatch_t *ptsmgpsendbatch, word *pwsenderr, word *pwrecverr );
5、byte getsendbatchresp( sendbatchresp_t *ptsendbatchresp, long npos, char smsgidfile[], bool *pblfileend );
6、byte smgpdeliver( smgpdeliverreq_t *ptsmgpdeliverreq, word *pwsenderr );
7、byte smgprecvsmreport( isreport_t *ptisreport, long npos, bool *pblfileend );
8、byte smgpactivetest( smgpactivetest_t *ptsmgpactivetest );
9、byte smgpexitmsg();
10、void closesmgpapi();
3动态库接口函数说明
(1) byte initsmgpapi( char sinifile[], hwnd hwnd, hinstance hinstance )
功 能: 应用程序( 进程 )刚启动时, 都必须首先用此函数进行通信初始化。
返 回: 成 功 返 回 0
失 败 返 回 1
输 入:hwnd ---- 应用程序的窗口句柄。
hinstance ---- 应用程序的实例。
sinifile。---- 配置文件名称和路径
(2) byte smgpsendlogin( char clientid[], char password[], word *pwsenderr, dword *pdwstatus, word *pwrecverr )
功 能:应用程序调用此函数发送login消息。
返 回:成 功 返 回 0
失 败 返 回 1
输 入:clientid ---- cp接入号。
password ---- cp接入密码。
输 出:*pwsenderr ---- 返回发送时的错误码。
*pdwstatus ---- 登录响应状态。
*pwrecverr ---- 返回接收时的错误码。
(3) byte smgpsendsingle( smgpsendsingle_t *ptsmgpsendsingle, word *pwsenderr, word *pwrecverr )
功 能:应用程序调用此函数向一个目的用户发送submit消息。
返 回:成 功 返 回 0
失 败 返 回 1
输 入:*ptsmgpsendsingle ---- sumit消息所需的发送信息,见消息体说明。
输 出:*pwsenderr ---- 返回发送时的错误码。
*pwrecverr ---- 返回接收时的错误码。
(4) byte smgpsendbatch( smgpsendbatch_t *ptsmgpsendbatch, word *pwsenderr, word *pwrecverr )
功 能:应用程序调用此函数向一个目的用户发送submit消息。
返 回:成 功 返 回 0
失 败 返 回 1
输 入:*ptsmgpsendbatch ---- sumit消息所需的发送信息,见消息体说明。
输 出:*pwsenderr ---- 返回发送时的错误码。
*pwrecverr ---- 返回接收时的错误码。
(5) byte getsendbatchresp( sendbatchresp_t *ptsendbatchresp, long npos, char smsgidfile[], bool *pblfileend )
功 能:应用程序调用此函数获得群发消息的响应信息。
返 回:成 功 返 回 0
失 败 返 回 1
输 入:npos ----消息体在文件中的位置,0表示第一条消息,1表示第二条消息…。
smsgidfile ---- 存放msgid的文件名。
输 出:*ptsendbatchresp ----响应消息体,见消息体说明。
*pblfileend ---- 返回文件是否结束,false表示未结束,true表示结束
注意:存放msgid的文件最多只能存放100条消息响应。(即npos值为0-99)
(6) byte smgpdeliver( smgpdeliverreq_t *ptsmgpdeliverreq, word *pwsenderr )
功 能:应用程序调用此函数获得群发消息的响应信息。
返 回:成 功 返 回 0
失 败 返 回 1
输 出:*ptsmgpdeliverreq ----deliver消息消息体,见消息体说明。
*pwsenderr ---- 返回发送时的错误码。
*pwrecverr ---- 返回接收时的错误码。
(7) byte smgprecvsmreport( isreport_t *ptisreport, long npos, bool *pblfileend
功 能:应用程序调用此函数获得群发消息的响应信息。
返 回:成 功 返 回 0
失 败 返 回 1
输 入:npos ----消息体在文件中的位置,0表示第一条消息,1表示第二条消息…。
输 出:*ptisreport ----状态报告消息体,见消息体说明。
*pblfileend ---- 返回文件是否结束,false表示未结束,true表示结束
注意:存放状态报告的名为../config/isreport.dat,若不存在../config目录则不产生状态报告文件,改文件最多只能存放100条消息响应。(即npos值为0-99)
(8) byte smgpactivetest( smgpactivetest_t *ptsmgpactivetest )
功 能:测试cp和网关之间的链路状态
返 回:成功返回 0
失败返回 1
输 入:*ptsmgpactivetest ---- 链路测试消息体,见消息体说明。
(9) byte smgpexitmsg()
功 能:注销cp接入
返 回:成功返回 0
失败返回 1
(10) closesmgpapi()
功 能:释放资源
应用程序结束时使用
现求一个C#写的代码 我的邮箱ghhp1978@163.com --------------------编程问答-------------------- 怎么没人回答啊 是不是嫌分少 我是新人 请各位大侠 帮帮忙啊
补充:.NET技术 , C#