请帮忙看一下这个DLL调用的函数,参数怎么写

ihpled 2010-07-23 12:08:02
pisn_getsnapshots
This function retrieves the most recent values sent to the pi System for an array of points. The snapshot values in engineering units, status codes, times, dates, and errors are returned in the passed parallel arrays. If the point type is not real, the value is returned in istat and the rval argument is returned as 0.

C format

int32 pisn_getsnapshots(
int32 PIPTR * pt
float PIPTR * rval,
int32 PIPTR * istat,
int32 PIPTR * timedate,
int32 PIPTR * error,
int32 count );
Returns
>0
System error
0
Success
-1
Point not found

Arguments
pt (passed)
Array of point numbers
rval (returned)
Array of values in engineering units, undefined for integer and digital points
istat (returned)
Array of statuses for type real points and values for integer and digital points
timedate (returned)
array of time stamps
error (returned)
Array of error codes
count(passed)
Size of the arrays
pi Toolkit Reference
GetSnapshot

以下是VB的定义
Declare Function pisn_getsnapshots Lib "piapi32.dll" (pt&, rval!, istat&, timedate&, piapierror&, ByVal count&) As Long

我是这样定义的
function pisn_getsnapshots(pt:array of Integer;rval:array of single;istat:array of Integer; timedate:array of Integer; error:array of Integer; count: Integer):Integer;stdcall;external 'piapi32.dll';


调用的时候
var
pt:array[0..20] of Integer;
rval:array[0..20] of single;
istat:array[0..20] of Integer;
timedatePt:array[0..20] of Integer;
errorPt:array[0..20] of Integer;
countPt: Integer

i:=getsnapshots(pt[0],rval[0],istat[0],timedatePt[0],errorPt[0],countPt);

i的值为0表示调用成功,但是rval[0]。。rval[20],的值都不正常,我把上面的句函数调用注释掉,rval[0]..ravl[20]的值仍不变,证明rval的数值在函数中没有被赋值,请高手帮忙看一下,是不是我的定义有问题,还是调用方法有问题


...全文
84 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
iqyely 2010-07-23
来膜拜下。
回复
keer005 2010-07-23
回复
kye_jufei 2010-07-23
伴水正解
回复
SuperTitan001 2010-07-23
俺是来膜拜清洁工大人的
回复
王集鹄 2010-07-23
又见“ array of Integer ”

Delphi里array of xxxx参数叫变体数组,信息包括了上下标信息。

C里的数组只能从0开始,这是就差别,数据类型都不一样。


大概会是这样:
type PSignle = ^Signle;

function pisn_getsnapshots(pt: PInteger;rval: PSingle;istat:PInteger; timedate:PInteger; error:PInteger; count: Integer):Integer;stdcall;external 'piapi32.dll';

var pt: array[0..9] of Integer;
var rval: array[0..9] of Single;
var istat: array[0..9] of Integer;
var timedate: array[0..9] of Integer;
var error: array[0..9] of Integer;

begin
pisn_getsnapshots(@pt[0], @rval[0], @istat[0], @timedate[0], @error[0], 10);
end;

回复
ihpled 2010-07-23
感谢伴水,感谢各位
回复
相关推荐
发帖
非技术区
创建于2007-08-02

802

社区成员

Delphi 非技术区
申请成为版主
帖子事件
创建了帖子
2010-07-23 12:08
社区公告
暂无公告