hello every body i just join us so .....
i have a little problem with a variant , i call in first step : "variantClear(&bbvariant)"

and after when i call a member of my bbvariant " _bstr_t (bbvariant.bstrVal).length() " is not equal to 0 , so i want to someone explain to me what happen when u call VariantClear,
if the length of my bstrVal is not 0 what's hapen ?

You have check _variant_t's vt member to find out the valid type of the variant. The value of vt after Clear() is called is 0, meaning that _variant_t object does not contain any valid data.

It's a very similar concept of deleting a string but not resetting the pointer to NULL. The pointer will still contain an address to some memory location where the array of characters resided but that memory location no longer is owned by the pointer and the contents of that memory location is subject to change at any time.

so thank's for u r helping nouveau dragon :) but look what i do :

-----------------------------

VariantClear(&bbvariant);
bbVariant=NULL;
if(bbVariant.vt == VT_BSTR) 
   TM_REPORT_MESSAGE(" ---> vt value is bstr ");
if((bbVariant.bstrVal).length() == 0) 
   TM_REPORT_MESSAGE(" ---> vt value is nul so i'm happy ");
 else
    TM_REPORT_MESSAGE(" ---> vt value is not null i'm frustred ");

-------------------------------------------------------------------

and the result is :

---> vt value is bstr
---> vt value is not null i'm frustred

--------------------------

no i'm inilizing the bbvariant as null so .
i supposed his member doesn't exist anywhere.!? but he is a bstr and he have a length !!! so

just for abored the last post because the result it's flase , but somone have a information or documentation for _variant_t , variantclear, variantinit , _bstr_t ? thank's for help

and the correct result is :
---------------------------------------------
---> vt value is nul so i'm happy
------------------------------------------------------

MSDN is the authority on _variant_t and VARIANT structure.

How is bbVariant declared? Is it _variant_t or VARIANT* ? If its _variant_t you don't need to call VariantClear(), but call it's Clear() method.

the bbvariant as declared as :

_variant_t bbvariant ;
and for clear variant i do :

VariantClear(&bbvariant);

i think it's right in this step , but i can't found a lot of information of _vatiant_t and his memeber methode in msdn for exemple i use
bbvaraint.bval i'm not found a documentation for this methode !???????

The docs are scarce for VARIANT types. bval is a BYTE (unsigned char) value type. You have to look in the header files where VARIANT is declared.

thank's for u help i found it , i think that he make a vt in status VT_EMPTY; i don't no what's his value but i'm going to found it , and going to make a construct response for my answers .

VariantClear() sets vt to VT_EMPTY, you don't have to do that yourself.

but in this case i do it myself , because i'm asking the variant if it is a _bstr_t and he say no , after vt is a bstr , so i init vt to vt_empty as in original case

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.