在dll中函数的定义如下:
int a1(int b1,
unsigned char *b2, //指向读到的文字信息
int b3, //指向读到的文字信息长度
unsigned char *b4,//指向读到的照片信息
int b5 //指向读到的照片信息长度
);在delphi中定义如下:function a1(b1:integer;b2:pchar;b3:integer;b4:pchar;b5:integer):integer;stdcall;external 'sdtapi.dll';调用如下:
var
b1:integer;b2,b4:array[0..2500] of char;b3,b5:integer;
iret:integer; buffer:pchar; iret:=a1(b1,@b2,@b3,@b4,@b5); strcopy(buffer,@b2); //取文字信息;-------这边取出的是乱码,只有数字还能看出来我这该怎么取呢?
int a1(int b1,
unsigned char *b2, //指向读到的文字信息
int b3, //指向读到的文字信息长度
unsigned char *b4,//指向读到的照片信息
int b5 //指向读到的照片信息长度
);在delphi中定义如下:function a1(b1:integer;b2:pchar;b3:integer;b4:pchar;b5:integer):integer;stdcall;external 'sdtapi.dll';调用如下:
var
b1:integer;b2,b4:array[0..2500] of char;b3,b5:integer;
iret:integer; buffer:pchar; iret:=a1(b1,@b2,@b3,@b4,@b5); strcopy(buffer,@b2); //取文字信息;-------这边取出的是乱码,只有数字还能看出来我这该怎么取呢?
如:WINAPI int a1(int b1,
unsigned char *b2, //指向读到的文字信息
int b3, //指向读到的文字信息长度
unsigned char *b4,//指向读到的照片信息
int b5 //指向读到的照片信息长度
);
因为这个函数类型定义,决定了参数b1:integer;b2:pchar;b3:integer;b4:pchar;b5:integer;的压栈顺序,类型不对,参数传就不正确,返回的结果,自然就不会对了.
int WINAPI a1(int b1,
unsigned char *b2, //指向读到的文字信息
int b3, //指向读到的文字信息长度
unsigned char *b4,//指向读到的照片信息
int b5 //指向读到的照片信息长度
);
将b2,b4:array[0..2500] of char 定义为b2,b4 为pchar 取的时候用@b2也还是不行,取出的还是乱码!
将b2,b4:array[0..2500] of char 定义为b2,b4 为pchar 取的时候用@b2也还是不行,取出的还是乱码!你定义了一个字符串数据,在调用函数之前,先复位一下,
fillchar(b2,sizeof(b2),0);
iret:=a1(b1,@b2,b3,@b4,b5);//b3,b5,不要加@这样试试
unsigned char *b2, //指向读到的文字信息
int b3, //指向读到的文字信息长度
unsigned char *b4,//指向读到的照片信息
int b5 //指向读到的照片信息长度
);这个是不是,你VC的函数类型,,,,如果是的话,
我觉得有点问题; 你的注释说,b3,b5指向读到信息的长度,是用来返回的吧但是你这样int b3,int b5定义,b3,b5,是没有办法返回值的.
应该是这样
int WINAPI a1(int b1,
unsigned char *b2, //指向读到的文字信息
int *b3, //指向读到的文字信息长度
unsigned char *b4,//指向读到的照片信息
int *b5 //指向读到的照片信息长度
);
int a1(int b1,
unsigned char *b2, //指向读到的文字信息
int *b3, //指向读到的文字信息长度
unsigned char *b4,//指向读到的照片信息
int *b5 //指向读到的照片信息长度
);但没有WINAPI ,dll已经封装好了,动不了的