在delphi中调用的格式是这样的:
int Test (int * nParam1 , char *nParam2[20000]);VB中怎么声明这个API,具体怎么调用阿!
小弟在这老出问题,不是访问内存错误就是咳!偶是这么声明的
Public Declare Function Test Lib "C:\api.dll" _
(ByRef nParam1 As Integer, _
ByRef nParam2() As Byte) As Integer希望各位老大帮忙给个详细答案哈,拜谢了!
int Test (int * nParam1 , char *nParam2[20000]);VB中怎么声明这个API,具体怎么调用阿!
小弟在这老出问题,不是访问内存错误就是咳!偶是这么声明的
Public Declare Function Test Lib "C:\api.dll" _
(ByRef nParam1 As Integer, _
ByRef nParam2() As Byte) As Integer希望各位老大帮忙给个详细答案哈,拜谢了!
Public Declare Function Test Lib "C:\api.dll" _
(Byval nParam1 As long, _
ByRef nParam2 As Byte) As long
调用时nParam2 参数传入byte数组的第一个元素,而nParam1参数到底传入什么,则取决于这个参数是输入参数还是输出参数,如果用于输入的话,直接传入参数即可,如果用于输出的话,则传入参数的指针
(ByRef nParam1 As Integer, _
ByRef nParam2 As Byte()) As IntegerPublic Declare Function Test Lib "C:\api.dll" _
(ByRef nParam1 As Integer, _
ByRef nParam2 as any) As Integer
(ByRef nParam1 As Long, _
ByRef nParam2 As Byte) As Long调用
Dim ret As Long
Dim p1 As long
Dim p2(20000) As Byte
......
ret = Test(p1, p2(0))或Public Declare Function Test Lib "C:\api.dll" _
(ByRef nParam1 As Integer, _
ByVal nParam2 As String) As Long '如果Param2的值全为可打印字符调用
Dim ret As Long
Dim p1 As long
Dim p2 As String * 20000
......
ret = Test(p1, p2)
Public Declare Function Test Lib "C:\api.dll" _
(ByRef nParam1 As Long, _
ByVal nParam2 As String) As Long '如果Param2的值全为可打印字符
我给个实际成功的Delphi例子, VB就是不出结果
声明:
function Test(var nParam1: integer; var nParam2: PChar): Integer; Stdcall;External'api.dll';
调用:
p1,p2:pchar;
nPa2: integer;
r: integer;
nPa1:array[0..20000] of char;p1 := nPa1;
r := Test(nPa2,p1);偶试过是完全成功。
但是按楼上的2种方法,没报错,但是就不出结果啊。
郁闷啊郁闷
1:
Public Declare Function Test Lib "C:\api.dll" _
(Byval nParam1 As long, _
ByRef nParam2 As Byte) As long
调用:
dim p1 as long
dim p2() as byte
redim p2(2000)
dim ret as long
ret=test(varptr(p1),p2(0))
2:
Public Declare Function Test Lib "C:\api.dll" _
(Byval nParam1 As long, _
byval nParam2 As long) As long
调用:
dim p1 as long
dim p2() as byte
redim p2(2000)
dim ret as long
ret=test(varptr(p1),varptr(p2(0)))
如果你有函数原型的话,最好给出来另外,如果这个api不依赖特殊设备的话,建议给出下载地址,这么猜来猜去也不是办法//我给个实际成功的Delphi例子, VB就是不出结果
我不知道"不出结果"具体是什么意思,是函数没执行成功吗?还是函数执行成功了,但你取不到参数的值,如果是后者的话,你还需要处理byte数组
------------------------------------
我就得就函数申明本身而言,可以这样申明:'第二个参数不全为可打印字符Declare Function Test Lib "C:\api.dll(ByRef nParam1 As Long,ByVal nParam As Long) As Longdim p1 as long
dim p2(0 to 1999) as byte
dim ret as long
ret=test(p1,VarPtr(p2(0)))'如果第二个参数为可打印字符Declare Function Test Lib "C:\api.dll(ByRef nParam1 As Long,ByVal nParam As String) As Long'调用见of123() 给大代码
int DeliverfromEsm (int * BufCount , char *Buffer[20000]);第一个是短信的条数,第二个是存放短信的按照各位的方法实际进行测试,结果是: 首先可以执行,不会报错; 但是我用监视窗口看
第二个参数,和第一个参数都没有结果,就是说都没有受到短信。按照上面给的Delphi的方法(是开发商提供的)可以收到短信。
BufCount:Buffer中短信的个数;
此接口一旦调用成功后,接收到的MO短信被保存在buffer中,最大返回100个消息。