请教一个在DLL中使用回调函数的问题(50分)

F

forza

Unregistered / Unconfirmed
GUEST, unregistred user!
我使用VC做了一个DLL,其中一个输出函数为:
int myfunction(const char*,struct mystruct*,int,void(* myfirst)(struct mystruct *),void(* mysecond)(char *,int,int));
我要在DELPHI中调用这个函数,其中的myfirst,mysecond为回调函数
在DELPHI中的定义为
unit _mylib;
interface
type
  proce1 = procedure (a : pointer);//我想在过程中再强制转换指针类型
proce2 = procedure (mystring : string; i,j:integer);
function myfunction(str : Pchar; struct1 : pmystruct,i : integer;myfirst : proce1; mysecond : proce2):integer;cdecl;
implemetation
function myfunction(str : Pchar; struct1 : pmystruct,i : integer;myfirst : proce1; mysecond : proce2):integer;cdecl;external 'mylib.dll';
其中的pmystruct也在这个文件中定义了,与在VC下的结构是一致的(我认为是对的,因为在程序的其它部分是正确的)。
在另外一个UNIT中我定义了:
procedure myfirst(a:pointer);
procedure mysecond(mystring : string; i,j:integer);

并调用了myfunction.
在调试中,DLL一使用myfirst时(在DLL使用myfirst前,我输出一个MessageBox 是正常的) ,就错误跳出,报内存xxxxxxx(基本都是0,最后是一个1)不能'read'.
使用mysecond时,第一个字符串类型是正确的,但后面的整型就不对了。
我用VC做了个测试的,DLL里的函数是没有问题的,在VC中调用可以正常。是不是由于跨平台的原因,
哪位大侠帮我解决一下,多谢了。
 
VC我不懂^_^
 
顶部