调用dll中函数出现访问0地址错误
调用dll中函数出现访问0地址错误
raised too many consecutive exceptions
我在dll中写了一个函数openfile(filename:pchar)函数
在其他程序中调用
myfilename:=pchar(extractfilepath(application.ExeName)+ 'answer\ '+ComBNum.Text+ '.ods ');
try
OpenFile(myfilename);
except
messagebox(handle, '没有文件可以打开 ', '警告 ',MB_OK);
出现上述错误,请帮忙!
[解决办法]
myfilename 是不是定义成了 PChar,而且没有初始化?
还有,PChar类型不是那么付值的。
可以使用如下方法:
var
myfilename: string;
begin
myfilename := extractfilepath(application.ExeName) + 'answer\ ' + ComBNum.Text + '.ods '
try
OpenFile(PChar(myfilename));
except
messagebox(handle, '没有文件可以打开 ', '警告 ',MB_OK);
end;
end;