C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-15-2009, 04:08 AM   #1
Registered User
 
Join Date: Jun 2009
Location: Bangalore,India
Posts: 23
How to convert string into LPCWSTR

Hii

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()
I've changed string to wstrig ,that time _findfirsti64() must have string argument...!!

any idea....


Thanking you..
krishnampkkm is offline   Reply With Quote
Old 06-15-2009, 05:06 AM   #2
int x = *((int *) NULL);
 
Cactus_Hugger's Avatar
 
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   Reply With Quote
Old 06-15-2009, 06:02 AM   #3
Cat without Hat
 
CornedBee's Avatar
 
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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 09:45 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22