1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
void * WINAPI BStr2TStr(HWND hwnd, BSTR strIn)
{
DWORD size;
void *strOut;
if (!IsWindowUnicode(hwnd))
{
// ANSI
size = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)((char *)strIn + 2), -1, 0, 0, 0, 0);
if ((strOut = GlobalAlloc(GMEM_FIXED, size)))
WideCharToMultiByte(CP_ACP, 0, (WCHAR *)((char *)strIn + 2), -1, (char *)strOut, size, 0, 0);
}
else
{
// UNICODE
size = (*((short *)strIn) + 1) * sizeof(wchar_t);
if ((strOut = GlobalAlloc(GMEM_FIXED, size)))
CopyMemory(strOut, (char *)strIn + 2, size);
}
return(strOut);
}
|