🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.tools.mfc
Article #123

Re: how to convert a CString into a VARIANT ??

#123
From: Frank Ostrowski
Date: Tue, 19 Dec 2000 22:27
44 lines
2274 bytes
On Tue, 19 Dec 2000 11:13:25 -0600, "Ali" <ali__2@yahoo.com> wrote:

>I have never used it but just from looking at it
>bstrVal is a BSTR, its a char *.  You can't just assign a string to it.
>
>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" <fviallet@com1.fr> wrote in message
>news:91o4be$pl$1@s1.read.news.oleane.net...
>> hi,
>>
>> 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
>>
>>

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
Technical Details
Message-ID: <3a3fdea0.13705425@news.cis.dfn.de>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!newsfeed.online.be!fu-berlin.de!uni-berlin.de!cele-3e36d8cd.pool.mediaways.NET!not-for-mail
References: <91o4be$pl$1@s1.read.news.oleane.net> <uIM%5.2397$SKV4.289276069@news.randori.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1138df,6492fccb20b167df
X-Google-Attributes: gid1138df,public
X-Google-Thread: f7a51,6492fccb20b167df
X-Google-Attributes: gidf7a51,public
X-Google-Thread: fdcad,6492fccb20b167df
X-Google-Attributes: gidfdcad,public
X-Google-Thread: 104d65,6492fccb20b167df
X-Google-Attributes: gid104d65,public
X-Google-Thread: 104971,6492fccb20b167df
X-Google-Attributes: gid104971,public
X-Google-ArrivalTime: 2000-12-19 14:27:08 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!newsfeed.online.be!fu-berlin.de!uni-berlin.de!cele-3e36d8cd.pool.mediaways.NET!not-for-mail
From: fr-ost@web.de (Frank Ostrowski)
Newsgroups: comp.os.ms-windows.programmer.tools.mfc,fr.comp.lang.c++,microsoft.public.vc.language,microsoft.public.vc.mfc,microsoft.public.vc.mfc.docview
Subject: Re: how to convert a CString into a VARIANT ??
Date: Tue, 19 Dec 2000 22:27:10 GMT
Lines: 44
Message-ID: <3a3fdea0.13705425@news.cis.dfn.de>
References: <91o4be$pl$1@s1.read.news.oleane.net> <uIM%5.2397$SKV4.289276069@news.randori.com>
NNTP-Posting-Host: cele-3e36d8cd.pool.mediaways.net (62.54.216.205)
X-Trace: fu-berlin.de 977264826 5092750 62.54.216.205 (16 [57564])
X-Newsreader: Forte Free Agent 1.21/32.243