我有用 FoxPro 编译的程序,它调用 d1.dll 函数。d1.dll 是使用 Delphi 2007 开发的。我需要开发 d1.dll,它将使用 c++ 替换现有的。经过几次测试后,FoxPro 应用程序在随机位置崩溃,并出现如下随机消息:
致命错误:异常代码=C0000005 @ 2012.12.12 11:33。错误日志文件:C:\Program Files\Common Files\Microsoft Shared\VFP\vfp9rerr.log
或者
没有足够的内存执行 some_function
我已经从 c++ dll 中删除了所有代码,只留下了一些原始 dll 通常返回的测试值。但这无济于事。声明和变量使用可能有问题。
我按照 Fox Pro 主程序中声明 d1.dll 函数的方式构建了 Fox Pro 小测试程序。不幸的是它没有崩溃。我从 IDE 运行它,而我的程序从可执行文件运行,但我认为这不是原因。可能有一些关于变量使用的问题。
可能有什么问题?
Delphi 和 C++ 中的函数声明:
C++
extern "C" int _stdcall f1(unsigned char *aError)
extern "C" int_stdcall f2(char *txt,unsigned char *aError)
extern "C" int _stdcall f3(unsigned char *aError, char *aAnswer)
extern "C" int _stdcall f4(unsigned char *aError)
extern "C" int _stdcall f5(char* 描述符, char x, double pr, char aError, double qtity, char kd, char* pd) extern "C" int _stdcall f6(char *acomment_string, unsigned char* aError)
extern "C" int _stdcall f7(unsigned chartender_number, double amount, unsigned char *aError)
extern "C" int _stdcall f8(unsigned char *aError)
德尔福 2007
函数 f1(var aError: byte):bool; 标准调用;函数 f2(txt: pchar; var aError: byte):bool; 标准调用;
函数 f3(var aError: byte; adata: pchar):bool; 标准调用;
函数 f4(var aError: byte):bool; 标准调用;
函数 f5(描述符:pchar;x:字节;pr:double;var aError:字节;数量:double;kd:pchar;pd:pchar):bool;标准调用;
函数 f6(non_fiscal_string: pchar; var aError: byte):bool; 标准调用;
函数 f7(tender_number:byte; 数量:double; var aError: byte):bool; 标准调用;
函数 f8 (var aError: byte):bool; 标准调用;
FoxPro 测试程序
FoxPro FoxPro
在 c:\d1.dll 字符串中声明整数 f1 错误
在 c:\d1.dll string txt,string err 中声明整数 f2
在 c:\d1.dll 中声明整数 f3 字符串错误,字符串 rec_nr
在 c:\d1.dll 字符串中声明整数 f4 错误
在 c:\d1.dll 中声明整数 f5 字符串描述,整数 x,双 pr ,字符串 err,双倍数量,字符串 kd,字符串 pd
在 c:\d1.dll 中声明整数 f6 字符串 non_fiscal_string,string err
在 c:\d1.dll 中声明整数 f7 整数投标,双倍金额,字符串错误
在 c:\d1.dll 字符串中声明整数 f8 错误
长度=2048
aCardinal=4
ff_log=空格(aLength)
rec_nr=空间(红衣主教)
财政记录=空间(红衣主教)
serial_nr = 空间(aLength)
状态字节=空间(红衣主教)
描述=“描述”
x =1 pr = 123 t=0 t= f2(descr,@kl)
t= f1(@kl)
Thisform.text1.Value=ff_log
t= f2(descr,@kl)
t= f4(@kl)
t=f3(@kl,@ff_log) t=GetStatus(@kl,rec_nr,fiscal_rec_nr,serial_nr,status_bytes)
t= f5(descr,x,pr,@kl, 1, "","")
t= f2(descr,@kl)
t= f2(descr,@kl)
t=f6(descr,@kl)
t=f8(@kl)
t=f7(1,100,@kl)