保存数据有关问题
保存数据问题!
以下程序为虹膜注册并保存采集到的虹膜数据,运行过程中出现弹出CPU窗口,提示
“access violation at 0x00402a21。。。。”信息,如果强行运行,就耗死。
数据库对应的字段为text类型,SQL server2000数据库。
什么问题,请大家帮忙看一下,先谢过。
.......
type
EnrollCallBack = procedure(enroll_info: Integer;const moban_buf: PByte; moban_size: Integer;const bitmap_buf: PByte; bitmap_size, bitmap_num: Integer);stdcall;
.......
function IRIS_enroll(pCB: EnrollCallBack): Integer; cdecl; external 'iris.dll';
//虹膜注册回调函数
procedure EnrollCB(enroll_info: Integer; const moban: PByte; moban_size: Integer;
const bitmap_buf: PByte; bitmap_size, bitmap_num: Integer);cdecl;
......
//虹膜注册回调函数说明
procedure EnrollCB(enroll_info: Integer; const moban:PByte; moban_size: Integer;
const bitmap_buf: PByte; bitmap_size, bitmap_num: Integer);cdecl;
begin
PathStr:=ExtractFilePath(ParamStr(0));
if enroll_info = ENROLL_INFO_OK then
begin
iris_str := string(moban);
isis_buf:= moban;
isis_size:= moban_size;
SaveIRIS(BasicNostr,iris_str);
Playsound(PChar(PathStr+'\sound\enroll_success.wav'),0,SND_ASYNC);
end
else if (enroll_info = ENROLL_INFO_CAOSHI)then
Playsound(PChar(ExtractFilePath(ParamStr(0))+'\sound\enroll_timeout.wav'),0,SND_ASYNC)
end;
//保存虹膜函数说明
procedure SaveIRIS(BasicNoStr:string;IrisData:string);
var ADOqueryTmp:TadoqUERY;
begin
ADOqueryTmp:=TADOQuery.Create(nil);
ADOqueryTmp.Connection:=DataM.ADOConn;
with ADOqueryTmp do
begin
close;
sql.Clear;
sql.Add('update Pro_BasicInf set Iris='''+IrisData+''' where
BasicNo='''+BasicNoStr+'''');
try
execsql;
showmessage('虹膜数据已保存!');
except
ADOqueryTmp.free;
exit;
end;
end;
end;
。。。。
//调用
procedure TGetIrisForm.BitBtn1Click(Sender: TObject);
var
RES :integer;]
error:BIILEAN;
begin
error := false;
BasicNostr:='';
BasicNostr:=Label3.Caption;
RES := IRIS_enroll(@EnrollCB);
if RES <> IRIS_OK then
begin
error := true;
end;
end;
------解决方案--------------------
cdecl修改成stdcall试试看。
The cdecl convention is useful when you call functions from shared libraries written in C or C++, while stdcall and safecall are recommended, in general, for calls to external code. On Windows, the operating system APIs are stdcall and safecall. Other operating systems generally use cdecl. (Note that stdcall is more efficient than cdecl.)
以下程序为虹膜注册并保存采集到的虹膜数据,运行过程中出现弹出CPU窗口,提示
“access violation at 0x00402a21。。。。”信息,如果强行运行,就耗死。
数据库对应的字段为text类型,SQL server2000数据库。
什么问题,请大家帮忙看一下,先谢过。
.......
type
EnrollCallBack = procedure(enroll_info: Integer;const moban_buf: PByte; moban_size: Integer;const bitmap_buf: PByte; bitmap_size, bitmap_num: Integer);stdcall;
.......
function IRIS_enroll(pCB: EnrollCallBack): Integer; cdecl; external 'iris.dll';
//虹膜注册回调函数
procedure EnrollCB(enroll_info: Integer; const moban: PByte; moban_size: Integer;
const bitmap_buf: PByte; bitmap_size, bitmap_num: Integer);cdecl;
......
//虹膜注册回调函数说明
procedure EnrollCB(enroll_info: Integer; const moban:PByte; moban_size: Integer;
const bitmap_buf: PByte; bitmap_size, bitmap_num: Integer);cdecl;
begin
PathStr:=ExtractFilePath(ParamStr(0));
if enroll_info = ENROLL_INFO_OK then
begin
iris_str := string(moban);
isis_buf:= moban;
isis_size:= moban_size;
SaveIRIS(BasicNostr,iris_str);
Playsound(PChar(PathStr+'\sound\enroll_success.wav'),0,SND_ASYNC);
end
else if (enroll_info = ENROLL_INFO_CAOSHI)then
Playsound(PChar(ExtractFilePath(ParamStr(0))+'\sound\enroll_timeout.wav'),0,SND_ASYNC)
end;
//保存虹膜函数说明
procedure SaveIRIS(BasicNoStr:string;IrisData:string);
var ADOqueryTmp:TadoqUERY;
begin
ADOqueryTmp:=TADOQuery.Create(nil);
ADOqueryTmp.Connection:=DataM.ADOConn;
with ADOqueryTmp do
begin
close;
sql.Clear;
sql.Add('update Pro_BasicInf set Iris='''+IrisData+''' where
BasicNo='''+BasicNoStr+'''');
try
execsql;
showmessage('虹膜数据已保存!');
except
ADOqueryTmp.free;
exit;
end;
end;
end;
。。。。
//调用
procedure TGetIrisForm.BitBtn1Click(Sender: TObject);
var
RES :integer;]
error:BIILEAN;
begin
error := false;
BasicNostr:='';
BasicNostr:=Label3.Caption;
RES := IRIS_enroll(@EnrollCB);
if RES <> IRIS_OK then
begin
error := true;
end;
end;
------解决方案--------------------
cdecl修改成stdcall试试看。
The cdecl convention is useful when you call functions from shared libraries written in C or C++, while stdcall and safecall are recommended, in general, for calls to external code. On Windows, the operating system APIs are stdcall and safecall. Other operating systems generally use cdecl. (Note that stdcall is more efficient than cdecl.)