W
wjy2334
Unregistered / Unconfirmed
GUEST, unregistred user!
一个用Delphi写的动态链接库,其中一个函数的声明是这样的:
ReadRegister(PraAddr:integer,PraNum:byte;var cPraVal:array of word):boolean;stdcall
我试了以下三种方法:
方法一:
typedef BOOL (_stdcall *READREGISTER)(int,BYTE,WORD (*cPraVal)[]);
READREGISTER ReadRegister=(READREGISTER)GetProcAddress(hInst,"ReadRegister"
WORD cPraVal[2];
ReadRegister(0x90,2,cPraVal);
编译时出错:error C2664: 'int (int,unsigned char,unsigned short (*)[])' : cannot convert parameter 3 from 'unsigned short [2]' to 'unsigned short (*)[]'
方法二:
typedef BOOL (_stdcall *READREGISTER)(int,BYTE,WORD* cPraVal);
后编译连接不会出错,不过在程序运行时会出现错误提示框,内容为:
The value of ESP was not properly saved across a function call.This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
方法三:
分两部分定义,先定义:
typedef WORD (*WORD_ARRAY)[]
再定义:
typedef BOOL (_stdcall *READREGISTER)(int,BYTE,WORD_ARRAY);
出现和第一种方法一样的错误
我没招了,那位兄弟帮帮我啊?谢谢了
ReadRegister(PraAddr:integer,PraNum:byte;var cPraVal:array of word):boolean;stdcall
我试了以下三种方法:
方法一:
typedef BOOL (_stdcall *READREGISTER)(int,BYTE,WORD (*cPraVal)[]);
READREGISTER ReadRegister=(READREGISTER)GetProcAddress(hInst,"ReadRegister"
WORD cPraVal[2];
ReadRegister(0x90,2,cPraVal);
编译时出错:error C2664: 'int (int,unsigned char,unsigned short (*)[])' : cannot convert parameter 3 from 'unsigned short [2]' to 'unsigned short (*)[]'
方法二:
typedef BOOL (_stdcall *READREGISTER)(int,BYTE,WORD* cPraVal);
后编译连接不会出错,不过在程序运行时会出现错误提示框,内容为:
The value of ESP was not properly saved across a function call.This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
方法三:
分两部分定义,先定义:
typedef WORD (*WORD_ARRAY)[]
再定义:
typedef BOOL (_stdcall *READREGISTER)(int,BYTE,WORD_ARRAY);
出现和第一种方法一样的错误
我没招了,那位兄弟帮帮我啊?谢谢了