Jump to content
Snieres

LabView DLL creates weird double array

Recommended Posts

I have a type LabView created DLL that creates the following structure:

 

typedef struct {
	int32_t dimSizes[2];
	double elt[1];
} DoubleArrayBase;
typedef DoubleArrayBase **DoubleArray;

void __stdcall SimpleDoubleArray(int32_t Channels, int32_t Points, 
	DoubleArray *DoubleArray);

In Delphi have defined the structure as follows:

type
  PDoubleArray = ^DoubleArray;
  DoubleArray = ^PDoubleArrayBase;
  PDoubleArrayBase = ^DoubleArrayBase;
  DoubleArrayBase = packed record
    dimSizes: array[0..1] of Int32;
    elt: array[0..0] of Double;
  end;

var
  procedure SimpleDoubleArray(Channels, Points : Int32; TestDoubleArray: PDoubleArray);stdcall; external DLLDirectory;

and call the function :

procedure TForm8.btn1Click(Sender: TObject);
var
  TestDoubleArray : DoubleArray;

begin
  SimpleDoubleArray(5,5,@Testdoublearray);
end;

 

My question is that when i assign the DoubleArray as the output of a function, how do i read the information that is stored in the TestDoubleArray?  In other words, how do i access the DoubleArrayBase record values of dimSizes and elt from the TestDoubleArray variable that i passed to the function? I am basically translating what is done in this post: https://lavag.org/topic/20486-lv-dll-creates-mysterious-doublearray-class/ to a Delphi equivalent. 

Edited by Snieres

Share this post


Link to post

We don't know what PDoubleArray1 is because the definition isn't here.  However, you pass @Testdoublearray which is a pointer to pointer to record.  But the native code expects pointer to struct.  Clearly a mismatch.  Given the various edits that have gone on between the real code and the code you posted, this could be wrong.

Edited by David Heffernan

Share this post


Link to post

Yes Remy, it is. I have updated the question on stack. What you have is correct, but how do i go about viewing the data stored in the doublearray? It is more of a carry on question. I can not figure out how to get to the dimsizes and the elt through the DoubleArray. I have broken this question down to a basic 2d array.

Edited by Snieres

Share this post


Link to post
13 minutes ago, Snieres said:

Yes Remy, it is. I have updated the question on stack. What you have is correct, but how do i go about viewing the data stored in the doublearray?

I just answered that on StackOverflow, go see my update.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×