From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cannot get the element of array by LabVIEW Array Handle in DLL

Solved!
Go to solution

the vc code follows: 

 

#include "extcode.h"

/* LabVIEW created typedef */
typedef struct {
 int32 dimSize;
 double elt[1];
} TD1;
typedef TD1 **TD1Hdl;

extern "C"
{
 _declspec(dllexport) void CINRun(TD1Hdl input,double *output);
};

 _declspec(dllexport) void CINRun(TD1Hdl input,double *output)
{
 //cannot get the first element of the array passed from labview to DLL
 *output=(*input)->elt[0];


 //if change the code above with follows
 //*output=(*input)->dimSize;
 //then it is successful to get the size of one dimension array.
 //So,what's the matter?
}

 

the vc project and labview program are attached.

 

the problem is:run the labview program, cannot get the right result from the array 

 

thanks

chen

帖子被chenyin在 02-16-2010 12:28 AM
时编辑过了
Download All
0 Kudos
Message 1 of 5
(3,253 Views)
Solution
Accepted by topic author chenyin

You have made two errors:

 

Error 1 (alignment!):

 

Err1.png

 

Error 2: passing parameters:

 

Err2.png

 

Change it as shown above and it should be OK. 

 

Andrey.

0 Kudos
Message 2 of 5
(3,236 Views)

thank Andrey Dmitriev

you help me out of a big problem.

So, how do you know the errors?

Now I just have only one manul about DLL attached and I haven't found anything about you said above in this manul.

 

0 Kudos
Message 3 of 5
(3,226 Views)

chenyin wrote:

thank Andrey Dmitriev

you help me out of a big problem.

So, how do you know the errors?

Now I just have only one manual about DLL attached and I haven't found anything about you said above in this manual.

 

 


 

The answer is: "Experience + RTFM"

 

Please read the following topic: Re: Array of doubles filled by DLL contains weird values

 

Andrey.

Message 4 of 5
(3,222 Views)

thank you Andrey Dmitriev

thanks!It's very useful!

0 Kudos
Message 5 of 5
(3,217 Views)