![]() |
| | #1 |
| Registered User Join Date: Jun 2009 Location: Bangalore,India
Posts: 23
| How to convert string into LPCWSTR How can I convert string into LPCWSTR Code: struct FILELIST
{
string path;
vector<string> theList;
};
string path
list<FILELIST>& theList
struct _finddatai64_t data;
string fname = path + "\\*.*";
long h = _findfirsti64(fname.c_str(),&data); //_findfirsti64(string,)
---------------
----------------
---------------
//here I wanna convert string to LPCWSTR ....
//using the LPCWSTR I've to open the file using Createfile()
any idea.... Thanking you.. |
| krishnampkkm is offline | |
| | #2 |
| int x = *((int *) NULL); Join Date: Jul 2003 Location: Banks of the River Styx
Posts: 902
| 1) Call CreateFileA(). 2) Convert your string from whatever encoding it is in (presumably ASCII or UTF-8) to UTF-16. You can use MultiByteToWideChar() to accomplish this. Call it first with the last two arguments set to NULL and 0, respectively, and it will give you a buffer size. Allocate that buffer, call it again but passing the buffer, and you've got an LPWSTR. Then call CreateFileW(). Don't forget to free your memory.
__________________ long time; /* know C? */ Unprecedented performance: Nothing ever ran this slow before. Any sufficiently advanced bug is indistinguishable from a feature. Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31. The best way to accelerate an IBM is at 9.8 m/s/s. recursion (re - cur' - zhun) n. 1. (see recursion) |
| Cactus_Hugger is offline | |
| | #3 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,492
| Use a vector<WCHAR> if you convert yourself. But using CreateFileA is a better idea.
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| String editor for a sentence inputted by a user - any suggestions or ideas? | the_newbug | C Programming | 4 | 03-03-2006 02:11 AM |
| can anyone see anything wrong with this code | occ0708 | C++ Programming | 6 | 12-07-2004 12:47 PM |
| Classes inheretance problem... | NANO | C++ Programming | 12 | 12-09-2002 03:23 PM |
| ........ed off at functions | Klinerr1 | C++ Programming | 8 | 07-29-2002 09:37 PM |
| Warnings, warnings, warnings? | spentdome | C Programming | 25 | 05-27-2002 06:49 PM |