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: 

Pass Type to ActiveX Dll

Hi,

I'm trying to call an ActiveX DLL, that was written in Visual Basic 6. One of the parameters the function needs is of kind 'Type'. The Type contains several Integer and Booleans.
In Labview I tried to create a cluster, that contains the needed Integer and Boolean variables. I used I32 for the Integer variables. Then I connected the cluster to the Type parameter of the Invoke Node.
When I try to run it, I get an error message that contains the following text:
"LabVIEW:  An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @."

I tried to rebuild the problem in a simpler case. I just used a very simple function in a dll, that only uses one Type with one Integer in it and tried to call that from Labview (using a cluster, with one I32 in it). I get the same error. If I create a dll without the Type everything runs well.

So my problem is how to correctly model the Type in Labview in order to pass it to the function? I haven't found any really helpful information on that yet.

0 Kudos
Message 1 of 7
(3,130 Views)

Hello,

Are you referring to a 'struct'?  LabVIEW clusters do not match directly to C stuctures (see link).  You might be able to use Adapt to Type for the DLL parameter.

 

Regards,

Clint M
National Instruments

0 Kudos
Message 2 of 7
(3,088 Views)
Thanks for your response. yes, I'm using a kind of struct - in Visual Basic it is called a Type. As I am using a ActiveX DLL, I use the invoke Node function. Here I haven't been able to find the Adapt To Type option.
I also haven't been able to use the Call Library Function Node to call the ActiveX DLL. This results in an error: "function not found in library"
What to do here?
0 Kudos
Message 3 of 7
(3,078 Views)
I think what you are going to need to do is convert all of your data to arrays of U8's.  For example, if your type was one !32, and the value you wanted to pass was 256, then you would have an array of U8's = { 0, 0, 1, 0}.  You can accomplish this using the Typcast function and using an array of U8's as the type.

LabVIEW clusters contain binary information outside of the data in the cluster, so your Type may be expected 4 bytes in my example above, but LabVIEW is added overhead for the cluster.  You can use the Typecast on the cluster with array of U8's as the type, and the ouput will not have any overhead associated with the cluster (at least in LV 8.5, but I believe this behavior predates LV 8.5).

Try it and let us know.
Message 4 of 7
(3,077 Views)
I am not sure if this is exactly what you described, so I will let you know what I did:

This is the source of the DLL in Visual Basic:


Type Struct
    varA As Integer
End Type

Public Sub TestStruct(testedStruct As Struct)

End Sub


pretty simple - it does just nothing... takes a Type that consists of 1 Integer.


Here is what I did in Labview. I used the Type Cast with the array of 4 U8 as Type to Convert the Cluster and then passed it to the fuction. The Array contains 4 U8s and the Cluster contains 1 I32.
I also included the error message in the screenshot.
I'm pretty new to Labview, so maybe this might just be a pretty obvious thing for some of you. Thank you so far.




Message Edited by sthu on 09-19-2007 08:55 AM

0 Kudos
Message 5 of 7
(3,038 Views)
Have you verified the error is indeed occuring at your property node?  You aren't using the error cluster and the error message isn't telling you where the error is occuring.  Either turn on Highlist Execution to see where the eror occurs, or wire up the error clusters and probe them to verify the error is occuring at the Property node.

I would assume it is, but better to be sure.

You did what I had suggested.  For reference, the array can be empty for the typecast.  It shouldn't make a difference, but you should add a "o Variant" between the output of the Typecast and the Input of the Property Node.

Also, verify via probe that the output of the Typecast has 4 elements in the array.

Message Edited by Matthew Kelton on 09-19-2007 09:22 AM

0 Kudos
Message 6 of 7
(3,035 Views)
I just tried that - to me it seems that the error occurs at the invoke node function. But to make sure I will attach another screenshot. Hope that helps.

0 Kudos
Message 7 of 7
(3,030 Views)