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

Hybrid View

  1. #1
    Join Date
    May 2001
    Posts
    7

    Conversion: CString to PCWSTR

    How do I convert a CString to a PCWSTR?

    Thanks.


  2. #2
    Join Date
    Apr 2000
    Location
    San Francisco, California, USA
    Posts
    4,467

    Re: Conversion: CString to PCWSTR

    CString str;

    USES_CONVERSION;
    PCWSTR psz = T2CW(str);

    Make sure to include <afxconv.h> in your stdafx.h file.


    Russian Software Development Network -- http://www.rsdn.ru

  3. #3
    Join Date
    Feb 2001
    Location
    Sydney, Australia
    Posts
    1,909

    Re: Conversion: CString to PCWSTR

    Hi !

    Try that code:

    CString str = "lalala";

    #ifdef _UNICODE
    PCWSTR p = LPCTSTR(str);
    #else
    USES_CONVERSION;
    PCWSTR p = A2CW(LPCTSTR(str));
    #endif

    rate it if ... blah-lah-lah

    Best regards,

    -----------
    Igor Soukhov (Brainbench/Tekmetrics ID:50759)
    igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
    Best regards,
    Igor Sukhov

    www.sukhov.net

  4. #4
    Join Date
    Apr 2000
    Location
    San Francisco, California, USA
    Posts
    4,467

    Re: Conversion: CString to PCWSTR

    It is worth to note that

    #ifdef _UNICODE
    PCWSTR p = LPCTSTR(str);
    #else
    USES_CONVERSION;
    PCWSTR p = A2CW(LPCTSTR(str));
    #endif

    is exactly how T2CW macro works.


    Russian Software Development Network -- http://www.rsdn.ru

  5. #5
    Join Date
    Feb 2001
    Location
    Sydney, Australia
    Posts
    1,909

    Re: Conversion: CString to PCWSTR

    Cool ! =)

    Best regards,

    -----------
    Igor Soukhov (Brainbench/Tekmetrics ID:50759)
    igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
    Best regards,
    Igor Sukhov

    www.sukhov.net

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