extern "C" _declspec(dllexport) short _stdcall k4chg(short *chgtype, short *nent ,short *pString)
//参数说明
// " pString "为short数组,对应于ASCII值,共15个数,
//
// chgtype为short型的变量,控制最后的输出模式,chgtype的值为1,2,3,4,5函数根据这个变量,重写pString指向的数组
// nent为short型的变量,控制最后是否需要回车符,nent的值为0,1,0表示不需要回车换行符,1表示需要回车换行符。函数k4chg( )处理数据后,重写pString指向的数组内容.
//参数说明
// " pString "为short数组,对应于ASCII值,共15个数,
//
// chgtype为short型的变量,控制最后的输出模式,chgtype的值为1,2,3,4,5函数根据这个变量,重写pString指向的数组
// nent为short型的变量,控制最后是否需要回车符,nent的值为0,1,0表示不需要回车换行符,1表示需要回车换行符。函数k4chg( )处理数据后,重写pString指向的数组内容.
type PSmallint = ^Smallint;function k4chg(chgtype:PSmallint; nent:PSmallint; pString:PSmallint):SmallInt;stdcall;external '*.dll' name 'k4chg'
我是这样调用的,你看为什么不行呢
var
Form1 : TForm1;
ovtmp : olevariant; vtmp : variant;
btmp : byte;
inbuf : string;
dispy : string;
needenter : Smallint;
readtype : Smallint;
status : smallint; redata : array[1..15] of smallint;function k4chg(var w :Smallint;var c:Smallint;var d:Smallint):smallint;stdcall ;external 'generaldll.dll' name 'k4chg';procedure TForm1.MSComm1Comm(Sender: TObject);
var i: integer;
begin
ovtmp:=mscomm1.Input ; //接收数据
vtmp:=ovtmp;
inbuf:=vtmp;
for i:=1 to 13 do
begin
redata[i]:=integer(inbuf[i]); //将数据转换为ASSCII数组
end; readtype:=ComboBox1.ItemIndex+1;
status:=k4chg(readtype,needenter,redata[1]); //调用动态连接库进行数据校验和数据格式转换
dispy:='';
for i:=1 to 13 do
begin
dispy:=dispy+chr(redata[i]);
end;
...
end;