LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass data to " TD1 **TD1Hdl" data type from C# or C++

How to pass data to " TD1 **TD1Hdl" data type from C# or C++?
My LabVIEW DLL has created the following *.h file.


#include "extcode.h"
#pragma pack(push)
#pragma pack(1)

#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
 int32_t dimSize;
 LStrHandle OneString[1];
 } TD1;
typedef TD1 **TD1Hdl;


void __cdecl StartApplet(TD1Hdl *OneArrayOfStrings,  TD1Hdl *OneMoreArrayOfStrings);
void __cdecl GetWndRect(int16_t *left, int16_t *top, int16_t *right,  int16_t *bottom);

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

#ifdef __cplusplus
} // extern "C"
#endif

 

#pragma pack(pop)

0 Kudos
Message 1 of 9
(3,597 Views)

Hey Sandeepvd,

 

Are you trying to access a DLL created in a different language? One way you could do this is by using the Call Library Function Node.

Please expand upon what you would like this program to do.

Ricky

National Instruments
Applications Engineer
0 Kudos
Message 2 of 9
(3,569 Views)

Thanks.

 

What I am trying to do is to pass the parameters to LabVIEW DLL (from a C#, C++ DLL) as 2 arrays of strings.

That's where LabVIEW creates the function definitions mentioned.

 

Thanks for CallLibraryFunctionNode. I am unsure if it is applicable. Since LabVIEW is not a parent in my case. It is a (grand)child which gets called from a child (C#/C++).

 

0 Kudos
Message 3 of 9
(3,532 Views)

Hey Sandeepvd,

 

So just to clarify, are you wanting to create a LabVIEW DLL? And then with this DLL created from LabVIEW you want to pass parameters that originate from a third language, go to C# and then call this LabVIEW DLL?

Ricky

National Instruments
Applications Engineer
0 Kudos
Message 4 of 9
(3,507 Views)

This is correct.

Thank you.

0 Kudos
Message 5 of 9
(3,485 Views)

Hey Sandeepvd,

Take a look at this Knowledge Base Article: How Can I Pass a Multidimensional Array from Visual Basic to a LabVIEW-Built...

I hope this can help.

Ricky

National Instruments
Applications Engineer
0 Kudos
Message 6 of 9
(3,472 Views)

I have run into a similar problem while writing a program using a LabVIEW generated DLL and using it in C# (VS2010). The knowledgebase article gives no useful information and is incomplete in what information it provides.

 

Is there any sample code or other resources relating to the subject?

0 Kudos
Message 7 of 9
(3,357 Views)

Hey mgerceker,

I have not been able to find much about using a LabVIEW DLL with C# (VS2010), but I did find an example using VB.NET to call LabVIEW DLL's. I hope this can be of some assistance, perhaps a baseline to see how it can be done.

NI Developer Zone: Simple Example Using VB.NET to Call LabVIEW DlLs
NI Developer Zone: Using VB.NET to Call LabVIEW DLLs That Use 2D Numeric Arrays

Ricky

National Instruments
Applications Engineer
0 Kudos
Message 8 of 9
(3,330 Views)

Ricky,

 

Unfortunately I do not have access to anything older than LV8.6 and cannot use the build scripts for them. Furthermore the pointer access scheme in C# requires the use of manual Marshalling, which makes it harder to deal with handles. I have solved my problem by reshaping my arrays in wrapper functions before and after the real function call, but I am sure there'll be consequences as far as performance is concerned.

 

Thank you,

 

Mehmet

0 Kudos
Message 9 of 9
(3,300 Views)