Yeh I get a little confused with all this unicode stuff LOL. All I know is this. If it has a squiggly, Give it an L LOL.
Anyway I tried wchar_t and indeed I could send it to the messagebox without problems, but for some reason it is not getting the letter.
Strange if I add a break point I find that resText has the value of 'S' and for some reason firstChar does not show up at all when I hit the breakpoint. Which is wierd.
Anyway I know firstChar hasn't got the value of 'S' because I get a blank messagebox on the screen.
Code: Select all
HGLOBAL hMem = LoadResource(hInstance, hRes);
DWORD size = SizeofResource(hInstance, hRes);
char* resText = (char*)LockResource(hMem);
char* text = (char*)malloc(size + 1);
memcpy(text, resText, size);
text[size] = 0;
void* lockedRes = LockResource(hMem);
// Now use this for the first char, for example:
//char firstChar = ((char*)lockedRes)[0];
wchar_t firstChar = ((char*)lockedRes)[0];
MessageBox(NULL, LPCWSTR(firstChar), TEXT("TEXT"), NULL);