This is a VB docking do Com interface, memory block has been taken to//now traverse each element of the structure, but not how to read, they still hope everybody to give directions, never had this experience
PosLogInfo=the packed record
ReadMark: Byte;
CardNo: Double;
SFType: Smallint;
SFMealTypeID: Smallint;
SFAmount: Double;
CardBalance: Double;
SFDate: TDateTime;
CardUseTimes: Integer;
SFOpterNo: Smallint;
OrderDate: TDateTime;
ProductID: array [0.. 9] of Integer;
ProductNum: array [0.. 9] of Integer;
end;
function SafeArrayToText (p: PSafeArray) : string;
Var
RBound: TVarArrayBound;
I, UCount: Integer;
Xfinfo: PosLogInfo;//record consumption structure
The begin
VarResultCheck ((SafeArrayGetLBound (p, 1, RBound LowBound)));
VarResultCheck (SafeArrayGetUBound (p, 1, UCount));
RBound. ElementCount:=UCount - RBound. LowBound;
//the number of elements, not wrong, in line with the interface prompt 22.
//now traverse each element of the structure, but not how to read, they still hope everybody to give directions, never had this experience
For I:=RBound. LowBound to RBound. ElementCount do
The begin
FillChar (xfinfo, SizeOf (xfinfo), 0).
//that don't know how to write, arguably is right, but I don't know what's going on, read the value is always wrong, and each is the same actually
VarResultCheck (SafeArrayGetElement (p, I, xfinfo));
Memo1. Lines. The Add (" CardNo: "+ FloatToStr (xfinfo. CardNo));
Memo1. Lines. The Add (' SFType: + FloatToStr (xfinfo. SFType));
Memo1. Lines. The Add (' SFAmount: + FloatToStr (xfinfo. SFAmount));
Memo1. Lines. The Add (' CardBalance: + FloatToStr (xfinfo. CardBalance));
Memo1. Lines. The Add (+ formatdatetime 'SFDate:' (' ', xfinfo. SFDate));
end;
end;
//FillChar has clear 0 structure, traverse value is the same, all specifications should already have the assignment, but also not
CardNo: 0
SFType: 5120
3.79442416006077 e-321 SFAmount:
6.21476085095821 e-317 CardBalance:
SFDate: 1899-12-30
CardNo: 0
SFType: 5120
3.79442416006077 e-321 SFAmount:
6.21476085095821 e-317 CardBalance:
SFDate: 1899-12-30
CardNo: 0
SFType: 5120
3.79442416006077 e-321 SFAmount:
6.21476085095821 e-317 CardBalance:
SFDate: 1899-12-30
CardNo: 0
SFType: 5120
3.79442416006077 e-321 SFAmount:
6.21476085095821 e-317 CardBalance:
SFDate: 1899-12-30
CodePudding user response:
SafeArrayGetElement (p, I, xfinfo); What's pSafeArrayGetElement (target array, the array indexing number, read the count of group)
CodePudding user response: