Re: 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
Hi Senthil,
Although I can't take the time to research a full solution, you're clearly dealing with a conflict between single byte and multi byte strings. I run into this all the time with CE. The compiler is using the wide char version of CreateFile (CreateFileW) which needs wide char parameters (wchar_t), yet str is a single byte string (char). You'll need to switch one or the other - either get rid of the multi byte compiler option, or make str a multi byte string.
Re: 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
This is off the subject a little but most functions manipulating characters have a _w_ version such as wprintf for printf but what can you use in place of atof to make your code portable?
EDIT: sorry, I found it. _wtof for anyone interested. Not sure of why the underscore is used though.
Re: 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
Originally Posted by CornedBee
The underscore is because it's a compiler extension, not part of the standard.
What exactly do you mean by handle?
1) I decided to use ostringstream and istringstream for conversion back and forth between numeric and text.
2) Lets say you are compiling in Unicode and declare some std::wstrings. There is no portable or generic way (that I know of) to switch right to Multi-Byte without changing all of your std::wstring references to std::string.
Re: 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
Nothing simpler. std::string and std::wstring are both just typedefs in the first place. The real stuff is a template called std::basic_string, which gets instantiated (among other things) with the character type. Like this:
Getting a switching string therefore is as simply as
Code:
typedef std::basic_string<TCHAR> tstring;
Then just use tstring everywhere and you're all set.
The same applies to many more things: std::istream is a typedef for std::basic_istream<char>, std::istringstream for std::basic_istringstream<char>. They all have wchar_t versions, and you can instantiate them all with TCHAR.
Ah, the walk down memory lane. To think that I, too, once wanted to derive from std::string.
I attached my tcpp.h. Note that the file is a few years old. It violates the C++ standard by introducing new names into the std namespace, so you should change that, but otherwise it's still fine.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.