06-15-2010 08:31 AM
I am using Call Library Function, trying to pass a structure to the function in dll.
The function is like this:
int DllFunc(int a, DLLSTRUCT dllstruct);
The structure is simply like this:
typedef _DLLSTRUCT
{
int a;
int b;
char c;
} DLLSTRUCT;
I created a cluster like the structure, and tried to use "Adapt to Type", "Handles by Value" to pass the structure to the dll function. LabVIEW crashes.
I guess it actually passes in the pointer to the structure, not the structure.
Is there a way to pass in the structure to DLL?
Otherwise I will have to create a wrapper function.
Thanks for any input.
06-15-2010 09:31 AM
06-15-2010 09:52 AM
Thanks.
I took a look at the "Call Dll" example, the Cluster example has Function Prototype: void CLUSTERSimple(TD1 *input, TD1 *output); in which input is a structure pointer.
The Function I am trying to access is passing in the structure, Not the pointer, such as void CLUSTERSimple_str(TD1 input, TD1 *output); can I do this?
06-15-2010 11:07 AM
06-15-2010 12:47 PM
Then I think I will have to use a wrapper function.
Thank you.
06-16-2010 04:47 AM
Your cluster is 72 bits, right?
Shame it's not 64 or less because you could then trick LV into wrapping your data in a U64 (using the cast function) scalar and pass that (willingly telling LV to pass it as something other than it actually is).
I don't see a way of passing more than 64 bits by value with the call library node.
Looks like you really need a wrapper DLL.
Shane.
06-16-2010 06:56 AM
Yes, it is more than 64bits.
But thanks for the trick.
08-18-2011 10:12 AM
How could i do this Wrapper function?
Respectively how could i handle with the following problem in C#
i have this in my header-file of the SharedLib.h
typedef struct { LVBoolean status; int32_t code; LStrHandle source; } TD1; void __cdecl IP_Supply_GET_Current(TD1 *FehlerEingang, LVBoolean *Start, TD1 *FehlerAusgang, LVBoolean *End); long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
and try to make a project with this rudimentary start:
namespace IP_GET_Current { /** interface TestInterface { Boolean status{ get; set; } } **/ public class Class1 /**: TestInterface**/ { [DllImport("C:\\SharedLib.dll", EntryPoint = "IP_Supply_GET_Current", ExactSpelling = false)]; static extern unsafe void IP_Supply_GET_Current(Int32 code, Boolean Start, Boolean End, Int32 code); public struct TD1{ Boolean status; Int32 code; } Boolean Start; Boolean End; public Main() { IP_Supply_GET_Current(3,true,true,2); } } }
How can i start to solve the problemß
Thanks
08-19-2011 04:47 PM
Arphex,
I am not sure what you are asking for. Are you looking for help writing the wrapper? Are you trying to write a dll to call from LabVIEW?
If this is specifically related to C# or .NET, you may find better resources at the MSDN forums, since this is a primarily LabVIEW forum. However, if you can help us understand a little bit better what you need help with, we may be able to help you as well.
Thanks, and good luck!