LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variant Input Parameters with ActiveX Objects

I've created an ActiveX library that exports a variety of objects using Visual C++ Version 6.0. I'm testing the methods and properties of these objects using both LabVIEW and Visual Basic clients. The problem I'm facing is that when testing under LabVIEW, I can't access methods that expect a VARIANT input parameter. The declaration in C++ of one object's such method looks like this:

void CChassis::Configure (VARIANT config, int rate);

I can create the ActiveX object with both LabVIEW and Visual Basic. I can invoke methods that do not use VARIANT input parameters using both as well; but, when I create a second ActiveX Object (a CConfiguration) and use the LabVIEW Variant operator, my attempt to invoke Configure fails with a "No Such Interface (E_NOINTERFACE)" error. The invocation fails identically if I wire the CConfiguration directly to the Variant input, as well. If I instead create a constant VARIANT as an input parameter, my Configure method gets called, although the method recognizes that I passed an invalid object.

Using Visual Basic I can invoke the Configure method without problems while encapsulating a CConfiguration object within a Variant.

So my question is, have I found a LabVIEW error, or is my approach flawed? If my approach is flawed, where have I gone wrong? Thanks in advance! I'm using LabVIEW version 7.0.
0 Kudos
Message 1 of 3
(2,682 Views)
Hi,

Have you tried to put in plain data or an object reference into your variant parameter?
I think plain data should work... for object references i don't know.
Some time ago, i also coded a small activex library, where i passed object references by parameters in delphi. I did not use variant parameters, but the real interfacedeclaration types (like IMyObject**). This worked fine. I also uses "dual" interfaces for the objects, which get passed by parameter. But i don't really know if this is helpfull for vb.

Finally, you can also use a workaround:
For each of your Objects, that you want to use from LabView and which you want to pass by a parameter, you
insert an new Property "int32 Object_Handle".
When an Object gets created, it ask a "ObjectHandleManager" (gets written by you) to get an own unique Object_Handle which it stores into its property "Object_Handle".
The ObjectHandleManager generates an new Object Handle and memorizes the Handle assoziated with the calling object's reference.
Now, at each time, when you want to pass a object reference to a library function of your self, you can pass the Object_handle as an integer value. In the called function, you can ask your ObjectHandleManager for the real ObjectReference.
But thats not a very comfortable workaround.
0 Kudos
Message 2 of 3
(2,675 Views)
I delved a little bit further, and I believe I may have found an error with LabVIEW. I determined that if the object I passed in the Variant had a custom interface, LabVIEW appears to be okay with the linkages, but doesn't invoke the right method when the application runs. If the object has a dual interface, LabVIEW calls the appropriate method. My solution was to convert my COM class' custom interface to a dual interface. Still, I think I've found a problem with LabVIEW.
0 Kudos
Message 3 of 3
(2,664 Views)