Re: Help on VARIANT/VT/VARTYPE
"Jess" <email@example.com> wrote in message
VT_BOOL is one of the values in VARTYPE enum, a possible type that a
VARIANT can hold.
Is VT_BOOL the type of VARIANT_TRUE and VARIANT_FALSE?
Which part of "one of the _values_ in VARTYPE enum" do you find unclear?
VT_BOOL it's a value, not a type. Assigned to VARIANT::vt, it indicates
that the variant holds a boolean value.
VARIANT_BOOL is just a typedef for short
What do you mean that VARIANT_BOOL is a typedef?
I mean that somewhere in Windows headers there's a line substantially
typedef short VARIANT_BOOL;
Is it an alias name
of some datatype? If so, what is the data type VARIANT_BOOL stands
Are you somehow reading only every other word of my post? I distinctly
remember saying "a typedef for short". Indeed, you even quoted this part
in your own response. I must admit I'm baffled.
One of the fields in the union inside VARIANT is named "boolVal", of
type VARIANT_BOOL. This is how one sets up a VARIANT holding a
v.vt = VT_BOOL;
v.boolVal = VARIANT_TRUE;
I see, then what if I'd like to set up a VARIANT holding, say, an
You would set v.vt to VT_I4, and assign your integer value to intVal.
Is there an equivalent field to boolVal, something like
Yes. Why don't you read the documentation on VARIANT and find out which
other fields it has?
Is there a way that I can convert the CComVariant v to VARIANT?
CComVariant is derived from VARIANT, and thus can be used anywhere
VARIANT is needed.
reminds me of another question: if I have a CComPtr, can I convert it
to an ordinary pointer?
CComPtr<Itf> provides operator Itf*(), so it's convertible to raw
pointer and can be passed where a raw pointer is needed. If for some
reason you find this insufficient, CComPtr<Itf*> has a public member
variable Itf* m_p
With best wishes,
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925