以下是别人给我的说明,对于以下的接口函数我何说明?
#ifndef ISO8583
#define ISO8583struct ISO_8583 {
int len;
unsigned char type;
unsigned char flag;
};struct len_str {
short len;
char *str;
};
struct data_element_flag {
short bitf;
short len;
int dbuf_addr;
};typedef struct {
struct data_element_flag f[128];
short off;
char dbuf[512];
char message_id[10];
} ISO_data;int strtoiso(unsigned char *, ISO_data * );
int isotostr(unsigned char *, ISO_data * );
int getbit(ISO_data *, int, unsigned char * );
int setbit(ISO_data *, int, unsigned char *, int );
void clearbit(ISO_data * );
int UnionDecKey(unsigned char *MK,unsigned char *WK,unsigned char *m_Key);
int UnionGenMac(unsigned char *MacKey,int MacDataLen,unsigned char *MacData,char *Mac);
#endif
#ifndef ISO8583
#define ISO8583struct ISO_8583 {
int len;
unsigned char type;
unsigned char flag;
};struct len_str {
short len;
char *str;
};
struct data_element_flag {
short bitf;
short len;
int dbuf_addr;
};typedef struct {
struct data_element_flag f[128];
short off;
char dbuf[512];
char message_id[10];
} ISO_data;int strtoiso(unsigned char *, ISO_data * );
int isotostr(unsigned char *, ISO_data * );
int getbit(ISO_data *, int, unsigned char * );
int setbit(ISO_data *, int, unsigned char *, int );
void clearbit(ISO_data * );
int UnionDecKey(unsigned char *MK,unsigned char *WK,unsigned char *m_Key);
int UnionGenMac(unsigned char *MacKey,int MacDataLen,unsigned char *MacData,char *Mac);
#endif
解决方案 »
- {DELPHI OBJECT PASCAL 语法精要样例}
- 如何实现treeview分开查询,不要一次全查出?
- 类不存在怎么办?
- 高手------超级简单 100相送5555555555555555555555555555555555555555555555
- deilphi6.0程序可不可以用InstallShield Express for Delphi4.0做安装?
- shadowfish进来拿分,内容见里面
- [delphi]line too long
- 怎么简单计算两个DATATIME类型数据之间隔了多少天?
- 有谁用过Delphi7里面的TSMTPServer组件啊?最好有简单例子。
- 求一简单键盘钩子的用法,---焦点不在我所写的程序时,按F4键触发我一段程序
- 如何让active form 界面初始化时显示一棵树
- HO HO 如何动态执行delphi程序?像exec('select * from '+@tablename)一样
typedef struct {
struct data_element_flag f[128];
short off;
char dbuf[512];
char message_id[10];
} ISO_data;
TDate = record
D: 1..31;
M: TMonth;
Y: 1900..1999;
end;
这个文件是别人给我的,我只管在delphi中引用
现在的总题是我如何在delphi中声明它!
你主要是定义结构,以及声明函数,再就是引入DLL
我觉得模仿VCL的相关单元就行了
struct data_element_flag {
short bitf;
short len;
int dbuf_addr;
}; 对应Delphi结构说明Tdata_element_flag:
Type Tdata_element_flag=Packed Record
bitf: short; // 可能对应word;
len: short;
dbuf_addr: Integer;
end;-----------------------------------------
typedef struct {
struct data_element_flag f[128];
short off;
char dbuf[512];
char message_id[10];
} ISO_data; 对应Delphi结构说明 ISO_data,ISO_data是类型名:Type ISO_data=Packed Record
f: Array[0..128] of Tdata_element_flag;
off: short;
dbuf: Array[0..511] of char;
message_id: Array[0..9] of char;
End; 注意:请查一下short在VC中的存储表示,如两个字节则对应Word,……。
in vc中若用#pragma pack(1)指定编译,则要用packed 申明Record ,否则不要最好用sizeof,测一下
没听明白,用sizeof ? 这是我的写的,大伙给点意见
unit useunit;interface type data_element_falg=record
bitf:integer;
len: integer;
dbuf_addr: integer;
end;
type ISO_data=record
f:array[0..127] of data_element_falg;
off:integer;
dbuff: array[0..511] of byte;
message_id:array[0..9]of byte;
end;
type piso_data=^ISO_data; function strtoiso(a:PByte;b:piso_data):integer;stdcall;
function isotostr(a:PByte;b:piso_data):integer;stdcall;
function getbit(a:piso_data;b:integer;c:PByte):integer;stdcall;
function setbit(a:piso_data;b:integer;c:PByte;d:integer):integer;stdcall;implementation
function strtoiso(a:PByte;b:piso_data):integer;stdcall;external 'iso8583';
function isotostr(a:PByte;b:piso_data):integer;stdcall;external 'iso8583';
function getbit(a:piso_data;b:integer;c:PByte):integer;stdcall;external 'iso8583';
function setbit(a:piso_data;b:integer;c:PByte;d:integer):integer;stdcall;external 'iso8583';
end.
type
ISO_8583 = record
len: Integer;
Type: Byte;
Flag: Byte;
end; len_str = record
len: Shortint;
str: PChar;
end;
data_element_flag = record
bitf: Shortint;
len: Shortint;
dbuf_addr: Integer;
end; ISO_data = record
f: array[0..127] of data_element_flag ;
off: Shortint;
dbuf: array[0..511] of Char;
message_id: array[0..9] of Char;
end;
PISO_data:=^ISO_data;function strtoiso(Buffer: PByte; Data: PISO_data): Integer;stdcall;external 'ISO8583.DLL';
function isotostr(Buffer: PByte; Data: PISO_data): Integer;stdcall;external 'ISO8583.DLL';
function getbit(Data: PISO_data; AInt: Integer; Buffer: PByte): Integer;stdcall;external 'ISO8583.DLL';
function setgit(Data: PISO_data; AInt: Inteegr; Buffer: PByte; BInt: Integer):Integer;stdcall;external 'ISO8583.DLL';
procedure clearbit(Data:PISO_data);stdcall;external 'ISO8583.DLL';
function UnionDecKey(MK: PByte; WK: PByte; m_Key: PByte): Integer;stdcall;external 'ISO8583.DLL';
function UnionGenMac(MacKey: PByte; MacDataLen: Integer; Mac: PByte): Integer;stdcall;external 'ISO8583.DLL';
找到一个转换工具
http://www.drbob42.com/tools/headconv.htm转换的结果如下: unit ISO8583;
{**************************************************************************}
{ }
{ This C DLL header file first (automatic) conversion generated by: }
{ HeadConv 4.0 (c) 2000 by Bob Swart (aka Dr.Bob - www.drbob42.com) }
{ Final Delphi-Jedi (Darth) command-line units edition }
{ }
{ Generated Date: 2003-10-7 }
{ Generated Time: 15:05:08 }
{ }
{**************************************************************************}interface
uses
{$IFDEF WIN32}
Windows;
{$ELSE}
Wintypes, WinProcs;
{$ENDIF}
{=> d:\documents and settings\netants\桌面\tmp\iso8583dll_bak_1\iso8583dll\ISO8583.H <=}{$IFNDEF ISO8583}
{$DEFINE ISO8583}type
ISO_8583 = record
{= ISO 8583 Message Structure Definitions }
len: Integer;
{= data element max length }
type: Byte;
{= bit 0--x, bit 1--n左对齐, bit 2--z bit 3--b }
flag: Byte;
{= length field length: 1--LLVAR型 2--LLLVAR型 }
end {ISO_8583};type
len_str = record
len: SmallInt;
str: PChar;
end {len_str};
type
data_element_flag = record
bitf: SmallInt;
len: SmallInt;
dbuf_addr: Integer;
end {data_element_flag};type
ISO_data = record
f: Array[0..128-1] of DATA_ELEMENT_FLAG;
off: SmallInt;
dbuf: Array[0..512-1] of Char;
message_id: Array[0..10-1] of Char;
end {ISO_data};
function strtoiso(var char*: Byte;
var _2: ISO_DATA): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF}; function isotostr(var char*: Byte;
var _2: ISO_DATA): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF}; function getbit(var _1: ISO_DATA;
_2: Integer;
var char*: Byte): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF}; function setbit(var _1: ISO_DATA;
_2: Integer;
var char*: Byte;
_4: Integer): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF}; procedure clearbit(var _1: ISO_DATA) cdecl {$IFDEF WIN32} stdcall {$ENDIF}; function UnionDecKey(var MK: Byte;
var WK: Byte;
var m_Key: Byte): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF}; function UnionGenMac(var MacKey: Byte;
MacDataLen: Integer;
var MacData: Byte;
Mac: PChar): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
{$ENDIF}implementationfunction strtoiso; external 'ISO8583.DLL';
function isotostr; external 'ISO8583.DLL';
function getbit; external 'ISO8583.DLL';
function setbit; external 'ISO8583.DLL';
procedure clearbit; external 'ISO8583.DLL';
function UnionDecKey; external 'ISO8583.DLL';
function UnionGenMac; external 'ISO8583.DLL';end.