How to convert string into LPCWSTR
-
Hii How can I convert string into LPCWSTR
struct FILELIST
{
string path;
vector<string> theList;
};string path
list<FILELIST>& theListstruct _finddatai64_t data;
string fname = path + "\\*.*";
long h = _findfirsti64(fname.c_str(),&data); //_findfirsti64(string,)
//here I wanna conver[B]t string to LPCWSTR[/B] ....
//using the LPCWSTR I've to open the file using Createfile()
I've changed string to wstrig ,that time _findfirsti64() must have string argument...!! any idea.... Thanking you..
-
Hii How can I convert string into LPCWSTR
struct FILELIST
{
string path;
vector<string> theList;
};string path
list<FILELIST>& theListstruct _finddatai64_t data;
string fname = path + "\\*.*";
long h = _findfirsti64(fname.c_str(),&data); //_findfirsti64(string,)
//here I wanna conver[B]t string to LPCWSTR[/B] ....
//using the LPCWSTR I've to open the file using Createfile()
I've changed string to wstrig ,that time _findfirsti64() must have string argument...!! any idea.... Thanking you..
You should really read this article[^], it will help you a lot understanding what you are doing wrong with your code. Basically, you should avoid these kind of conversions unless there is absolutely no other way. In your case, you can perfectly go without conversion. Your application is probably built for unicode support, so you should support that throughout your app: - use wstring if UNICODE is enabled by using your own string type everywhere in your app:
#if defined _UNICODE || defined UNICODE
typedef std::wstring TMyString;
#else
typedef std::string TMyString;
#endif- instead of using _findfirsti64, you should use the unicode independant version (_tfindfirsti64). You should have a look at the documentation for all those functions, there is always a table with the different versions. But anyway, first thing to do is to read the article :)
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++