* Michael Breidenstein:
anybody can help me to convert a "char *" to LPCWSTR with the following
function:
LPCWSTR charP2LPCWSTR(char *szText){
LPCWSTR tmp;
tmp=szText; // At this point I need help
return tmp;
}
As you may or may not know, LPCWSTR is _not_ a standard C++ type, so a
discussion of its usage is off-topic in this group.
However, assuming it is a type¹, then your function design seems a bit
dubious.
The argument is a char* pointer, which means the caller might modify
that string, and can/should not call the function with a string literal
or other constant string. If the "C" in LPCWSTR indicates "constant",
then that seems to be a needless restriction, which should be fixed by
declaring the argument as "char const*". On the other hand, if the
LPCWSTR type is not logically constant², then how is the original string
supposed to be updated to reflect changes done via the function result?
¹) I'm just presenting an on-topic argument here. For more detailed
answers you might ask in e.g. [comp.os.ms-windows.programmer.win32].
²) Again, I'm presenting an on-topic argument, ignoring that in all
likelyhood your LPCWSTR type is the same one as in the Win32 API.