Howdy, Stranger!

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

Categories

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

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [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]


  • Justin BibJustin Bib USAMember Posts: 0

    ______ [ http://forcoder.org ] free video tutorials and ebooks about \ PL/SQL, MATLAB, Java, Scratch, PHP, Assembly, Visual Basic, Perl, JavaScript, Ruby, Objective-C, Delphi, C#, Visual Basic .NET, Go, C, R, Swift, Python, C++ Ada, Clojure, Awk, Fortran, Transact-SQL, Erlang, VBScript, Kotlin, LabVIEW, D, Lisp, Rust, Logo, Lua, Crystal, Alice, Hack, FoxPro, ABAP, Scheme, Dart, Apex, Bash, Scala, ML, Julia, SAS, F#, COBOL, Prolog \ ___________

Sign In or Register to comment.