Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

typedef stuct array

How do I define my function from a DLL in C#? This part is confusing me ( TD1 *WaveformGraph). I want to output this value to a graph or to an array.
please help!


 C# DLL call function:

[DllImport("F.dll",CallingConvention=CallingConvention.StdCall)]
public static extern void Sound(IntPtr array, TD1 *WaveformGraph, int len);

--------------------------------------------------------------------------------------------------------------------------------------------------


The C header file generated from my labview exported DLL:


typedef
struct {
        
long dimSize;
        
double Numeric[1];
        } TD2;
typedef TD2 **TD2Hdl;

typedef struct {
        
double f0;
        
double df;
        TD2Hdl magnitude;
        } TD1;


void __stdcall Soundedr(double InputData[], TD1 *WaveformGraph, long len);

long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



0 Kudos
Message 1 of 3
(3,402 Views)

Hi OJG,

marshalling complex structures through platform invoke calls can be tricky. There are some great references for this online at msdn. I'd suggest starting here:

http://msdn2.microsoft.com/en-us/library/fzhhdwae.aspx

for an overview of platform invoke data marshaling, and then focus in on

Marshaling Classes, Structures, and Unions, especially the part on "Structure with a pointer to another structure."

0 Kudos
Message 2 of 3
(3,388 Views)

Orlando,

The first thing I would recommend would be to break up the cluster coming out of your VI.  Marshaling your data can be pretty tricky, but if you break it up you can bypass this problem.  You seem to have been able to bring one array into the code without any trouble.  You can follow the same procedure for the one inside the cluster once you have unbundled it in your VI.  The f0 and d0 will pass without much trouble as regular Doubles.

Also, don't forget to add the input parameter "device (0)" to your function call.  I don't see it in your C header file.

 

Regards,

Santiago D

0 Kudos
Message 3 of 3
(3,370 Views)