Article View: borland.public.cppbuilder.nativeapi
Article #10873Re: converting to LPCTSTR and LPTSTR
From: Remy Lebeau (TeamB)
Date: Fri, 12 Mar 2004 10:40
Date: Fri, 12 Mar 2004 10:40
25 lines
1951 bytes
1951 bytes
"Kevin Johnson" <kevjson@hotmail.com> wrote in message
news:40518921@newsgroups.borland.com...
> Many of the parameter used in these api's are of type LPCTSTR
> and LPTSTR. All my values are stored in AnsiStrings. So is there
> anyway to convert / type case to these two different types and if so,
> what is the best method.
If UNICODE is not defined for the project, then LPCTSTR and LPTSTR both map
to (const) char*, which is what AnsiString works with, so you can pass
AnsiString values directly to the API functions, ie:
SomeFunction(SomeString.c_str());
If, on the other hand, UNICODE is defined, then LPCTSTR and LPTSTR both map
to (const) wchar_t* instead, in which case you need to convert your strings
to UNICODE first, via MultiByteToWideChar(). You can call it directly, or
you can use a WideString, which handles AnsiString->WideString conversions
automatically for you.
SomeFunction(WideString(SomeString));
Gambit
Technical Details
Message-ID:
<4051918e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40518921@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,9c3ba41939a2b8bd X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-12 02:39:45 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40518921@newsgroups.borland.com> Subject: Re: converting to LPCTSTR and LPTSTR Date: Fri, 12 Mar 2004 02:40:39 -0800 Lines: 27 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <4051918e$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1079087502 67.22.138.253 (12 Mar 2004 02:31:42 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail