Home > Archive > Smartphone Developer Forum > April 2006 > Converting BYTE to LPWSTR
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Converting BYTE to LPWSTR
|
|
| Felix Khazin 2006-04-25, 10:04 pm |
| Hi,
I'm writing a plugin for WM5, but I can't find any explanations on how
to work with strings. This is what I have:
BYTE* pAllbyteData;
pAllbyteData = new BYTE[dwSizeLow];
if (ReadFile(hFile, pAllbyteData, dwSizeLow, &dwBytes, NULL))
{
LPCWSTR str = (TCHAR*) pAllbyteData;
DrawText(hdc, str, -1,
const_cast<RECT*>(&(ppe->p.paint.rcDraw)),DT_LEFT);
}
DrawText needs the string to be a LPCWSTR. This compiles fine, but when
I debug pAllbyteData contains the correct text, but then str contains
all boxes (the ones you get when a font can't be found).
Anyone have any ideas how I can get DrawText to print whatever is
returned in pAllbyteData?
Thanks,
Felix
| |
| Felix Khazin 2006-04-25, 10:04 pm |
| I figured it out:
BYTE* pAllbyteData;
pAllbyteData = new BYTE[dwSizeLow];
if (ReadFile(hFile, pAllbyteData, dwSizeLow, &dwBytes, NULL))
{
char* pfileData = (CHAR*) pAllbyteData;
WCHAR* wFilename;
MultiByteToWideChar(CP_ACP, 0, pfileData, -1, wFilename, dwSizeLow);
DrawText(hdc, wFilename,
-1,const_cast<RECT*>(&(ppe->p.paint.rcDraw)),DT_LEFT);
}
|
|
|
|
|