COleVariant question ... 
Author Message
 COleVariant question ...

Help !

How do I get the string out of COleVariant ?
I know it is in there.



Tue, 04 Dec 2001 03:00:00 GMT  
 COleVariant question ...
The same way you get it out of a VARIANT.  If the type is VT_BSTR, you can
just say BSTR text = olevariant.bstrVal.  If you want an ASCII string, then
you'll need to use a function like:

char* BSTRToAscii( BSTR inStr )
{
    BOOL udc = FALSE;
    long len = ::wcslen( inStr );
    char *pOutStr = new char[len+1];
    ::WideCharToMultiByte( CP_ACP, 0, inStr, -1, pOutStr, len+1, " ",
&udc );
    return pOutStr;

Quote:
}

This is specific to my needs in that it always new's a buffer for the
result, but you get the idea...

Dave Richards


Quote:
> Help !

> How do I get the string out of COleVariant ?
> I know it is in there.



Tue, 04 Dec 2001 03:00:00 GMT  
 COleVariant question ...
If you want to place the string in a CString variable, you can try this:

CString myString = V_BSTRT( &oleVariantVariable);

assuming it's of type VT_BSTR.

Quote:

>Help !

>How do I get the string out of COleVariant ?
>I know it is in there.



Thu, 06 Dec 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. COleVariant questions

2. COleVariant question

3. COleVariant( bstrVal ) Question

4. Question about COleVariant, CString and CByteArray

5. Bug in COleVariant(long lSrc, VARTYPE vtSrc) constructor...

6. COleVariant

7. Convert COleVariant to CString (or anything for that matter)

8. Converts a CByteArray variable to COleVariant and Vice-versa

9. Converting CString to COleVariant,etc..

10. COleVariant class object strips off any leading/trailing zeros

11. Difference between COleVariant & CComVariant

12. can't retrive a string from a COleVariant

 

 
Powered by phpBB® Forum Software