CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: BSTR to CString

  1. #1
    Join Date
    May 1999
    Posts
    63

    BSTR to CString

    When i try to read a BSTR in a COleVariant with

    CString Cs;
    Cs.Format("%s", Variant.bstrVal);

    my Cs contains just the first character of the string. Could you explain me why and what is the good methode to do this !

    ---------------------------------------------
    Laurent BERNARD
    Ingénieur Développement - Logiciel Visilog

    NOESIS
    6, rue de la réunion
    91940 Les Ulis

    E-mail : [email protected]

    Tél.: 01 64 86 78 50 poste 290
    ------------------------------------------------

  2. #2
    Join Date
    May 1999
    Location
    Seattle, WA USA
    Posts
    423

    Re: BSTR to CString

    CString Cs = Variant.bstVal;

    --michael


  3. #3
    Guest

    Re: BSTR to CString

    1. use _bstr_t.
    It has a char* operator.
    So, u can use it like this :
    _bstr_t my_bstr;
    CString s1 = (char*)my_bstr;

    Or
    2. You can try this:
    Variant.vt = VT_BSTR;
    CString s2 = V_BSTRT(&Variant);



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured