none
Convert char * to LPCTSTR

    Question

  • How I can convert char * to LPCTSTR.

    I reading msdn but I don't know nothing sensible to do.

     

    Thx for all hepl.

    Sunday, December 16, 2007 1:10 PM

Answers

  • I use "String Conversion Macros":

     

    LPCTSTR pszCharacterString = CA2W(pChar);

     

    where

     

    pChar is type char *

     

    and everything working fine

     

    Maybe this solution will help someone.

    Sunday, December 16, 2007 9:55 PM

All replies

  • http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=136598&SiteID=1

    maybe this will help, it worked for me.
    Sunday, December 16, 2007 8:05 PM
  • I use "String Conversion Macros":

     

    LPCTSTR pszCharacterString = CA2W(pChar);

     

    where

     

    pChar is type char *

     

    and everything working fine

     

    Maybe this solution will help someone.

    Sunday, December 16, 2007 9:55 PM
  • If your program is not using Unicode as the default, then "char *" is the same thing as LPCTSTR; the compiler will see the same thing, the only difference is that the preprocessor replaces LPCTSTR with "char *".

     

    Your program however is probably using Unicode as the default. If so, then you need to convert the non-Unicode "char *" string to a Unicode string. There are many ways to do that and the most convenient solution for you depends on what your program is already using. If your program is using MFC then there is a MFC solution. If your program is using the CLI (.Net) then there is a different solution using that. If your program uses the C++ standard classes (std namespace) then there is a solution using that. There is also a solution using the C runtime and anotehr using the Windows SDK.

    Monday, December 17, 2007 2:18 AM