LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Get OLE Variant Type?

How can I obtain the type of an OLE variant?  Using the "Variant to String" function always returns a type descriptor of "reference".  Looking at the control, the "Variant Type" attribute is present.  I found a previous thread here, but with no responses.

 

Since the OLE variant is a "reference", closing and re-opening the a VI will "lose" the data contained within the indicator.  Therefore, I cannot post a VI for testing of this.

 

The type is necessary so I can call the proper "Variant to Data" function.  My current work-around is to call the "Variant to Data" for all of the possible types (see image below) until I get an error.

 

 

Any help or advice would be appreciated!

CLA, CTA
Download All
0 Kudos
Message 1 of 9
(6,047 Views)

I don't know if they'll work for OLE Variant Data, but see if any of the functions in vi.lib\utility\VariantDataType\VariantType.lvlib can get you the information you need.  I'd try "Get Type Info.vi."  If that fails, you could try converting the variant directly to a string (with variant to data) and then look at that string to see if it tells you anything.  I had to do this with a complex type returned by an ActiveX call - all I could get from it was a string that I then had to parse into real data following the matching C structure definition.

0 Kudos
Message 2 of 9
(6,035 Views)

I tested various functions with the info shown below:

 

1. vi.lib\utility\VariantDataType\Get Type Info.vi

Returns "array" for everything

 

2. Flatten to string returns the same data for everything

no_ole_variant_information.PNG

 

 

The "variant type" attribute is displayed properly in a LabVIEW indicator.  There must be a way to access it...

 

Any other ideas?

CLA, CTA
Message 3 of 9
(6,027 Views)
0 Kudos
Message 4 of 9
(5,493 Views)

There is a library from MGI that might be useful for this.  Take a peek at the Cluster>VariantDataType pallette.

0 Kudos
Message 5 of 9
(5,466 Views)

Wayne,

 

No luck...

 

The MGI toolkit calls VIs in the vi.lib\Utility\VariantDataType\ directory.  I gave every VI a try in the pallete.  None of them return the type of data contained in the OLE variant.  The majority of them return Error 1.  The GetTypeInfo returns "External Data".

 

 

 

GetArrayInfo.vi
GetClusterInfo.vi
GetLVClassInfo.vi
GetNumericFxpInfo.vi
GetNumericInfo.vi
GetPolyVIInfo.vi
GetRandomNumberForType.vi
GetRefnumInfo.vi
GetStringInfo.vi
GetTagInfo.vi
GetTypedefPath.vi
GetTypeInfo.vi
GetUserDefinedClassRelationship.vi
GetUserDefinedRefnumInfo.vi
GetUserDefinedTagInfo.vi
GetUserDefinedTagRefnumInfo.vi
GetVIInfo.vi
GetWaveformInfo.vi


CLA, CTA
0 Kudos
Message 6 of 9
(5,457 Views)

The solution to this is to use a Call Library Node to call the LabVIEW manager function MoveBlock().

Configure the first parameter to be an ActiveX Variant, second parameter is an 16 bit integer passed as pointer to value, and the third is a 32 bit integer passed as value.

 

The function is in this post, with the name Get OLE Variant Type.vi.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 9
(4,206 Views)

Rolf, can you re-post your Get OLE Variant Type.vi here?  It is no longer available on the LAVA post.

0 Kudos
Message 8 of 9
(3,574 Views)

I’m on vacation with no access to my computer. But the description earlier should be almost all you need.

Call Library Node: Library Name: LabVIEW (case is important). Calling Convention: C

Function Name: MoveBlock

return value: void

1st Parameter: Active X Variant

2nd Parameter: uint16, passed as Pointer

3rd Parameter: pointer sized integer, passed by value

wire the Variant to the first Parameter and a constant with the value 2 to the third. The second parameter returns a value that matches the VT_ values from MSDN. https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/3fe7db9f-5803-4dc4-9d14-5425d3f...

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 9
(3,562 Views)