Reputation: 155
I am learning Microsoft OLE Automation and COM and it use VARIANT to pass data. I have read that it is union data structure but did not find enough information regarding this.
It would be helpful to me understand more about VARIANT as I am new to Automation and COM ?
Upvotes: 1
Views: 4539
Reputation: 139157
COM Automation defines a set of types that it knows how to marshal through thread or process boundaries.
It means there is no need for custom proxy/stubs if you restrict your interfaces to use only those types, and you describe your interface with a type library (most development tools, such as Visual Studio, do that automatically).
Those types are described here: VARENUM Enumeration.
The VARIANT type is itself an automation type, it's a struct that can contain any one of the other automation types.
COM Automation appeared with the Visual Basic development environment (up to version 6, before VB.NET). VB/VBA defines the same types (including Variant
).
Upvotes: 4
Reputation: 42528
A VARIANT is 16 bytes long. The first two bytes define the data type that the variant holds:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms221170(v=vs.85).aspx
The second half of the VARIANT holds the variable’s content. For more informations:
https://msdn.microsoft.com/en-gb/library/windows/desktop/ms221627(v=vs.85).aspx
Upvotes: 2