VB版的老大们,帮小弟看一下。还是VB调用VC DLL的问题,尝试多次无果。总是内存不能为"written"。函数原型:
int WINAPI CNGPSendSingle(
int nNeedReport,
int nMsgLevel,
const char* sServiceID,
int nMsgFormat,
const char* sFeeType,
const char* sFeeCode,
int nFeeUserType,
const char* sValidTime,
const char* sAtTime,
const char* sChargeTermID,
const char* sDestTermID,
int nMsgLen,
const char* sMsgContent,
char* sMsgID,
int* pnErrorCode,
BYTE* pnCongestionState
int nSubType,
const char* sSrcTermID );
我的声明:
Public Declare Function CNGPSendSingle Lib "CNGPDll.dll" (ByVal nNeedReport As Long, _
ByVal nMsgLevel As Long, _
ByVal sServiceID As String, _
ByVal nMsgFormat As Long, _
ByVal sFeeType As String, _
ByVal sFeeCode As String, _
ByVal nFeeUserType As Long, _
ByVal sValidTime As String, _
ByVal sAtTime As String, _
ByVal sChargeTermID As String, _
ByVal sDestTermID As String, _
ByVal nMsgLen As Long, _
ByVal sMsgContent As String, _
ByVal sMsgID As String, _
ByRef pnErrorCode As Long, _
ByVal pnCongestionState As Byte, _
ByVal nSubType As Long, _
ByVal sSrcTermID As String) As Long我的调用:
Dim ServiceID As String * 11
Dim FeeType As String * 3
Dim FeeCode As String * 7
Dim ValidTime As String * 18
Dim AtTime As String * 18
Dim ChargeTermID As String * 22
Dim DestTermID As String * 22
Dim MsgContent As String
Dim MsgID As String * 12
Dim ErrorCode As Long
Dim CongestionState As Byte
Dim SrcTermID As String * 22 ServiceID = "HELP" & Chr(0)
FeeType = "00" & Chr(0)
FeeCode = "000000" & Chr(0)
ValidTime = Chr(0)
AtTime = Chr(0)
ChargeTermID = Chr(0)
DestTermID = "03508827375" & Chr(0) 问题出在这里:如果是"8827375",就不会崩溃;如果是"03508827375",总是内存不能为"written"
MsgContent = "asd"
SrcTermID = "10680079" & Chr(0)MsgBox CNGPSendSingle(0, 0, ServiceID, _
15, FeeType, FeeCode, _
1, ValidTime, _
AtTime, ChargeTermID, _
DestTermID, 3, _
MsgContent, _
MsgID, ErrorCode, CongestionState, _
0, SrcTermID)
=========================================================================================
DestTermID = "03508827375" & Chr(0)
问题出在这里:如果是"8827375",就不会崩溃;
如果是"03508827375",总是内存不能为"written"
老大们帮小弟看一下,多谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
int WINAPI CNGPSendSingle(
int nNeedReport,
int nMsgLevel,
const char* sServiceID,
int nMsgFormat,
const char* sFeeType,
const char* sFeeCode,
int nFeeUserType,
const char* sValidTime,
const char* sAtTime,
const char* sChargeTermID,
const char* sDestTermID,
int nMsgLen,
const char* sMsgContent,
char* sMsgID,
int* pnErrorCode,
BYTE* pnCongestionState
int nSubType,
const char* sSrcTermID );
我的声明:
Public Declare Function CNGPSendSingle Lib "CNGPDll.dll" (ByVal nNeedReport As Long, _
ByVal nMsgLevel As Long, _
ByVal sServiceID As String, _
ByVal nMsgFormat As Long, _
ByVal sFeeType As String, _
ByVal sFeeCode As String, _
ByVal nFeeUserType As Long, _
ByVal sValidTime As String, _
ByVal sAtTime As String, _
ByVal sChargeTermID As String, _
ByVal sDestTermID As String, _
ByVal nMsgLen As Long, _
ByVal sMsgContent As String, _
ByVal sMsgID As String, _
ByRef pnErrorCode As Long, _
ByVal pnCongestionState As Byte, _
ByVal nSubType As Long, _
ByVal sSrcTermID As String) As Long我的调用:
Dim ServiceID As String * 11
Dim FeeType As String * 3
Dim FeeCode As String * 7
Dim ValidTime As String * 18
Dim AtTime As String * 18
Dim ChargeTermID As String * 22
Dim DestTermID As String * 22
Dim MsgContent As String
Dim MsgID As String * 12
Dim ErrorCode As Long
Dim CongestionState As Byte
Dim SrcTermID As String * 22 ServiceID = "HELP" & Chr(0)
FeeType = "00" & Chr(0)
FeeCode = "000000" & Chr(0)
ValidTime = Chr(0)
AtTime = Chr(0)
ChargeTermID = Chr(0)
DestTermID = "03508827375" & Chr(0) 问题出在这里:如果是"8827375",就不会崩溃;如果是"03508827375",总是内存不能为"written"
MsgContent = "asd"
SrcTermID = "10680079" & Chr(0)MsgBox CNGPSendSingle(0, 0, ServiceID, _
15, FeeType, FeeCode, _
1, ValidTime, _
AtTime, ChargeTermID, _
DestTermID, 3, _
MsgContent, _
MsgID, ErrorCode, CongestionState, _
0, SrcTermID)
=========================================================================================
DestTermID = "03508827375" & Chr(0)
问题出在这里:如果是"8827375",就不会崩溃;
如果是"03508827375",总是内存不能为"written"
老大们帮小弟看一下,多谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
解决方案 »
- 执行程序提示 windows 正在设置 Micrsoft office professional Edition 2003,请稍后
- 根据当前窗口 判断IE,并控制IE 请教
- 使用Winsock控件编程访问网页的问题
- [求帮]关于TreeView的问题.
- 紧急求救:各位大虾,怎样在vb中把系统的beep声音给屏蔽掉?
- 急!!!怎么样用EXCEL做报表呀
- 一个string最长支持多少字节?
- 用ADO访问DBASE V的数据库,可以吗?
- 有谁用过oracle odbc driver 连接oracle数据库(8.1.6)
- 高分求教——怎样识别条形码扫描仪的输入?
- VC编写的DLL给VB调用,输出字符串的时候为什么字符串会有尾巴呢
- sos 数据库连接问题
int WINAPI CNGPSendSingle(
int nNeedReport,
int nMsgLevel,
const char* sServiceID,//[11]: this stands for the string has 11B space;
int nMsgFormat,
const char* sFeeType, //[3]
const char* sFeeCode, //[7]
int nFeeUserType, //[7]
const char* sValidTime, //[18]
const char* sAtTime, //[18]
const char* sChargeTermID, //[22]
const char* sDestTermID, //[22]
int nMsgLen,
const char* sMsgContent,
char* sMsgID, //[11]
int* pnErrorCode,
BYTE* pnCongestionState,
int nSubType, //[2]
const char* sSrcTermID //[22]
);
int* pnErrorCode,
BYTE* pnCongestionState以上三个字段为返回值。
Dim DestTermID(22-1) As byte
当然,你的声明也要改一下
ByVal sDestTermID As String
修改为:
sDestTermID As any(或者as byte)
调用时,传入数组的首个元素DestTermID(0)
int* pnErrorCode,
BYTE* pnCongestionState以上三个字段为返回值。
--------------------------------
既然这三个字段为返回值,那么在函数声明中都应该为ByRef引用啊,你的声明中好像不是。
声明更改
ByVal pnErrorCode As Long, _
ByRef pnCongestionState As Byte, _
多谢 暴风雨 老大。