Home > Back-end >  Delphi programming about PSafeArray type variable data acquisition
Delphi programming about PSafeArray type variable data acquisition

Time:09-24

Receive a PSafeArray type of return value, don't know how to read the content inside!!!!!

The function TEngine. RoiCoordArrayGet (const bstrRoi: WideString; The out psanCoordsX: PSafeArray;
The out psanCoordsY: PSafeArray) : I_ENG_ERROR;
The begin
Result:=DefaultInterface RoiCoordArrayGet (bstrRoi psanCoordsX, psanCoordsY);
end;

Procedure TForm1. Button12Click (Sender: TObject);
Var
CoordsX CoordsY: PSafeArray;
XCor, YCor: Double;
The begin
//get ROI coordinate values
IReturn:=Engine1. RoiCoordArrayGet (' locator 1 'CoordsX CoordsY);
XCor:=CoordsX.?? ;//??? Don't know how to retrieve data from CoordsX and CoordsY content??
YCor:=CoordsY.?? ;//???
If iReturn=I_OK then
Showmessage (' RoiCoordArrayGet OK! ');
end;

CodePudding user response:

Jacked up!

CodePudding user response:

The function TEngine. RoiCoordArrayGet (const bstrRoi: WideString; The out psanCoordsX: PSafeArray;
The out psanCoordsY: PSafeArray) : I_ENG_ERROR;


This code is a c + + builder?
Literally means: PSafeArray should be a pointer to the structure, you should be the first to find it the definition of the dictionary is the statement of record
Call format if by default should be: XCor:=CoordsX ^. The corresponding structure element

CodePudding user response:

PSafeArray is a structure, related are defined as follows:

PSafeArray=^ TSafeArray;

TagSAFEARRAY=record
CDims: Word;//array dimension
FFeatures: Word;//used to describe how to allocate an array and a sign of how to be released
CbElements: Longint;//the size of the array element
CLocks: Longint;//a counter, used to track the number of the array is locked
PvData: Pointer;//a pointer to the data buffer
Rgsabound: array [0.. 0] of TSafeArrayBound;//describe an array of each dimension of array structure, the size of the array is variable
end;

SAFEARRAY array type parameters of the main purpose is for automation,
Three layer architecture usually need to use the ClientDataSet data set, you can convert the DataSet to SafeArray, again from other modules to receive,

CodePudding user response:

CreateDbClientObject (CLSID_DSBase IDSBase, FDSBase);
SafeArrayCheck (ActiveX. SafeArrayCopy (VarToDataPacket (Delta), DataPacket));
//SafeArrayCheck ();
Check (FDSBase, FDSBase AppendData (DataPacket, True));
FDSBase. SetProp (dspropXML_STREAMMODE xmlON);
Check (FDSBase, FDSBase StreamDS (DataPacket));
DataPacketToVariant (DataPacket VarPacket);
Result:=VariantArrayToString (VarPacket);

The code on the net;
I now take turns into detla PSafeArray key;
  • Related