tags:

views:

113

answers:

4

Is there any way to conver byte* message to LPCWSTR other than WideCharToMultiBYte()? Thanks Reply

Abhineet Agarwal

+3  A: 

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");
Nick D
A: 

wcstombs?

ctacke
A: 

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.

iconiK
A: 

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.

Abhi