Sign in to follow this  
kingpinzs

what is LPCTSTR

Recommended Posts

LPCTSTR is a windows typedef. It stands for Long Pointer to a Constant T String. A T string is a null terminated array that is of WCHARs when UNICODE is defined and CHARs when UNICODE is not defined.

Share this post


Link to post
Share on other sites
Ok well Ithough this should work but I will ask first and see if I did this right.

How can I use ifstream to load a file to LPCTSTR?

I am alos using dev c++ so I have no idea if I am using unicode or not.

Share this post


Link to post
Share on other sites
You probably aren't. Here's a way to check: do a sizeof(TCHAR) somewhere in your program and see what it spits out. If the result is 1 then you probably don't have UNICODE defined.

Share this post


Link to post
Share on other sites
I did get a 1. How do I define it?

I got that fixed but I dont think it will fix my problem.

I need to load LPCTSTR lpName from ifstream fin(filename);

Do I make filename a char, a string or what ?

[Edited by - kingpinzs on November 11, 2005 11:11:12 PM]

Share this post


Link to post
Share on other sites
Before you include a Windows-related headers, #define UNICODE.

Of course, the question is whether you want to define UNICODE: are your text assets in UNICODE, MBCS or ASCII?

As for loading data into an LPCTSTR using std::ifstream, if you're not using UNICODE then it's the same as loading into a char * buffer and passing that buffer to the function with LPCTSTR parameter. Alternately - and, frankly, better - load the data into a std::string and pass the return value of std::string::c_str() to the legacy (probably Win32 API) function that needs an LPCTSTR.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this