Is there any way to conver byte* message to LPCWSTR other than WideCharToMultiBYte()? Thanks Reply
Abhineet Agarwal
Is there any way to conver byte* message to LPCWSTR other than WideCharToMultiBYte()? Thanks Reply
Abhineet Agarwal
With byte*
I assume you mean a char*
string.
If that it is true, you can use swprintf
with the %hs
flag.
Example:
wchar_t msg[100];
swprintf(msg, L"%hs", "message");
mbstowcs if the encoding is the default one. Otherwise, you can use iconv from libiconv or use the Windows API function, it is very easy to use, just takes several lines of code.
Well i got the solution for it.
If you want to convert BYTE* to LPCWSTR other than using WideCharToMultiByte then we can use in the following way:
//Suppose BYTE * message; //where message="MessageRequest"
//now create one variable called "msg".... WCHAR msg[100]; //Copy "message" content into "msg" .
//Now take variable of LPCWSTR type LPCWSTR msg1; msg1=(LPCWSTR)msg;
//and display it using DrawText(...); //And u will be able to see proper message.