How Can I Convert From char* to LPCTSTR ??

Hi All ,

can any one please tell me How Can I Convert From char* to LPCTSTR .

thanks
hatem

Comments

  • [b][red]This message was edited by AsmGuru62 at 2002-10-21 8:24:43[/red][/b][hr]
    : Hi All ,
    :
    : can any one please tell me How Can I Convert From char* to LPCTSTR .
    :
    : thanks
    : hatem
    :
    [blue]Cool question!

    LPCTSTR is CONST TCHAR*

    TCHAR is a type which acts differently when you build your code with UNICODE and without it.

    For UNICODE: TCHAR = WCHAR
    NOT UNICODE: TCHAR = CHAR

    So, ATL has a set of macros to convert string types - one of them is A2T(). If you in just Windows API - you need to write it yourself:[/blue][code]
    #define A2T(dest,src)
    #ifdef UNICODE
    wcstombs (dest, src, 1 + wcslen (src));
    #else
    strcpy (dest, src);
    #endif
    [/code][blue]This macro assumes that 'dest' is a buffer declared as:

    char sBuffer [some room enough for 'src'];

    You can improve this macro to avoid the copying - just you need to declare a temporary buffer INSIDE the macro.[/blue]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion