Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AnsiString converstion to widechar's

Status
Not open for further replies.

jbs

Programmer
Feb 19, 2000
121
US
I'm using Borland C++ builder....for the first time.

I'm writing a quick application that will use Borlands standard "Open Dialog" component that will prompt the user with a list of file names to open via a very standard file open dialog box. The file name is returned in AnsiString format. I then need to take the filename and use it in a function that requires a LPTSTR that points to the string that contains the filename.

LPTSTR is a 32-bit pointer to a character string that is portable for Unicode.

Question: How do I convert the AnsiString to a Unicode string that is pointed to by a LPTSTR.

Here is my code to bring up the dialog box and get the filename (in AnsiString format).

AnsiString strFilename;
OpenDialog1->Execute;
strFilename=OpenDialog1->FileName;


Help??!!

 
Can this help you?

wchar_t *AnsiTowchar_t(AnsiString Str)
{
wchar_t *str = new wchar_t[Str.WideCharBufSize()];
return Str.WideChar(str, Str.WideCharBufSize());
delete str;
}
 
Thanks,....got it to work.

Much appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top