use : VC++ 6
how to do to convert a CString into a VARIANT ?
VARIANT v;
v.bstrVal="toto";
??
Thanks for help on the subject
Fred
something along this line.... or just do a new v.bstrVal = new char[100];
and then copy into it.
VARIANT v;
char *Temp[100];
strcpy(Temp,"toto");
v.bstrVal = Temp;
Ali
"Frédéric VIALLET" <fvia...@com1.fr> wrote in message
news:91o4be$pl$1...@s1.read.news.oleane.net...
Why not use the MFC class COleVariant? It has a constructor which takes a
CSting as a parameter.
Dave Smith
"Frédéric VIALLET" <fvia...@com1.fr> wrote in message
news:91o4be$pl$1...@s1.read.news.oleane.net...
Variant BSTR are not pointers to char. But pointers to specially
allocated Unicode Strings.
VARIANT v;
v.vt = VT_BSTR;
v.bstrVal = SysAllocString(L"toto");
Easier is to use the MFC supplied Variant wrapper, even including
automatic conversions from CString to and from Variant, and double,
int, DATE...
Frank
Dave Smith <Brind...@Compuserve.com> wrote in message
news:es1IBKeaAHA.1564@tkmsftngp03...
CString S;
CComBSTR bstr(S.AllocSysString());
_variant_t var(bstr);
==================================
"Frédéric VIALLET" <fvia...@com1.fr> wrote in message
news:91o4be$pl$1...@s1.read.news.oleane.net...
===================================
USES_CONVERSION;
CString s;
_variant_t var( A2W(s));
===================================
Tell me its not short....... :o)
"Frédéric VIALLET" <fvia...@com1.fr> wrote in message
news:91o4be$pl$1...@s1.read.news.oleane.net...
all works fine.
Regards,
Fred
"Julie" <michal...@contop.com> a écrit dans le message news:
uuZnp3oaAHA.2184@tkmsftngp05...