|
-
May 29th, 1999, 03:31 PM
#1
VARIANT
When I use some controls in VC,there have some function 's parameter type is VARIANT, how to invoke this type function?
Please help me!
-
May 29th, 1999, 07:57 PM
#2
Re: VARIANT
A VARIANT is a structure that contains all of the OLE types. It doesn't actually contain them, it is a union of them. So a VARIANT type occupies 12 bytes. Check out the documentation on http://msdn.microsoft.com. Basically the structure consists of the following.
struct VARIANT {
VARTYPE vt;
union {
Byte bVal; // VT_UI1.
Short iVal; // VT_I2.
long lVal; // VT_I4.
float fltVal; // VT_R4.
double dblVal; // VT_R8.
... and so on
You use it like the following.
VARIANT var;
// I am setting up the variant to hold a long value.
var.vt = VT_I4;
var.lVal = (long) 5;
There are also helper classes to help with the VARIANT structure.
MFC has a class, COleVariant, and there is a class, I use this one personally, defined in <comdef.h> called _variant_t. Check it out.
Hope this helps,
Wayne
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|