delphi调用dll,结构体作为参数

huxiaoqa 2012-08-17 01:33:01
调用总是不成功,请大家多赐教,谢谢

dll中的结构体和函数定义
struct Data_Task
{
char equitment_task_no[32];//检定任务编号EQUIPMENT_TASK_CODE
char bar_code[32];//设备条形码barcode
char goods_code[32];//到货批次号
char bar_type[32];//电表类别
};
DBADLLEXPORT int DBA_WriteData_Task(Data_Task *dataHead);

在delphi中的声明
type
Data_Task=record
equitment_task_no:array[0..31] of char;
bar_code:array[0..31] of char;
goods_code:array[0..31] of char;
bar_type:array[0..31] of char;
end;
P_Data_Task=^Data_Task;
function DBA_WriteData_Task(data_tast:P_Data_Task):Integer;stdcall;external 'dba_api.dll';

procedure TForm1.btn24Click(Sender: TObject);
var
tt:Data_Task;
begin
tt.equitment_task_no:='01';
tt.bar_code:='12345678';
tt.goods_code:='01';
tt.bar_type:='01';
edt2.Text:=IntToStr(DBA_WriteData_Task(@tt));
end;
...全文
447 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2012-08-17
  • 打赏
  • 举报
回复
确认下被调用的C dll函数的调用约定是否stdcall

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧