LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Sequence Context into Call Library Function Node

Hi Casey,

There is no problem to pass sequence context into modules of different nature (see previous posts). Actual task is: to develop single C interface for DLL (the DLL is still in development). This interface should accept sequence context. This interface should be accessible from TestStand, LabView and another DLL (automatically supported). The problem is that TestStand and LabView provide different ways of passing sequence context into DLL. The only solution I can imagine, is to export from DLL for each function additional one. Something like this:

void __declspec(dllexport) __stdcall TheFunction(struct IDispatch ** seqContextDisp);

void __declspec(dllexport) __stdcall TheFunction4TS(struct IDispatch * seqContextDisp){return TheFunction(&seqContextDisp);}

I would like to avoid using this solution. Anyone can help?

Thanks, Misha

0 Kudos
Message 11 of 17
(1,519 Views)
Hi Misha,
 
Thank you for clarifying exactly what you are trying to do. You should be able to pass an IDispatch ** from TestStand, LabVIEW, or another DLL. This way, your function prototype would look like:
 
 void __declspec(dllexport) __stdcall TheFunction(struct IDispatch ** seqContextDisp)
 
Using this prototype, you would not need to define a separate function for each calling application. I have tested out calling a DLL of this form on my end, and it appears to work great!
 
Regards,
 
Casey Weltzin
Applications Engineer
National Instruments
0 Kudos
Message 12 of 17
(1,505 Views)

Hi Casey,

This is what I tried to do (see "Reply 5 of 12"), but not succeeded.
When passing "ThisContext" "By Value", the error:

"No details available.; -17502; System Level Exception."

When passing "ThisContext" "By Reference" and "By Pointer", the error:

"Could not accept the parameters passed in. Only values of type 'Object Reference' may be passed 'By Reference' for this parameter.
Error in parameter 1, 'arg1'. ;-17311; Could not accept the parameters passed in."

Can you please explain how exactly you are pass sequence context from TestStand into function with this prototype (void __declspec(dllexport) __stdcall TheFunction(struct IDispatch ** seqContextDisp)).

Thanks, Misha.

0 Kudos
Message 13 of 17
(1,481 Views)

Hi Misha,

Thank you for your response. To pass the IDispatch ** from TestStand directly into your DLL, you should be able to use the following settings:

Category: Object
Type: ActiveX Automation IDispatch pointer
Pass: By Reference (by pointer)

With these settings, passing ThisContext as a parameter to your DLL should work great. I have tested this out on my end successfully, so I suspect that it should work correctly for you as well. Please let me know if this does not seem to work, or if you have any further questions and I would be glad to help you further.

Regards,

Casey Weltzin
Applications Engineer
National Instruments

0 Kudos
Message 14 of 17
(1,467 Views)

Hi Misha,

I have now been able to reproduce exactly what you are seeing. I was previously passing the RunState.Engine object as an IDispatch ** from TestStand to my DLL, but passing the sequence context as an IDispatch ** gives me the same error that you reported.

I will do some more research to determine why the sequence context cannot be passed as an IDispatch** as the engine object can. How do you intend on using the sequence context within your DLL? What specific functions are you running that require the sequence context as an input parameter?

Regards,

Casey Weltzin
Applications Engineer
National Instruments

0 Kudos
Message 15 of 17
(1,460 Views)

Hi Casey,

Within DLL sequence context  used to access TestStand API.

Thanks, Misha.

0 Kudos
Message 16 of 17
(1,442 Views)

Hi Misha,

After a lot of research, I do not think there is any way around the fact that TestStand and LabVIEW pass the Sequence Context to your DLL in different ways. What specifically are you hoping to accomplish with the TestStand API inside of your DLL? I would be glad to work with you to find a workaround.

Regards,

Casey Weltzin
Applications Engineer
National Instruments

0 Kudos
Message 17 of 17
(1,418 Views)