Dan Hipschman dsh@linux.ucla.edu writes:
INT WINAPI GetTextFaceA( HDC hdc, INT count, LPSTR name ) {
- INT res = GetTextFaceW(hdc, 0, NULL);
- LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 );
- GetTextFaceW( hdc, res, nameW );
- if (name) {
if (count && !WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count, NULL, NULL))
LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, count * sizeof nameW[0] );
INT res = GetTextFaceW( hdc, count, nameW );
if (count && res)
{
WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count, NULL, NULL); name[count-1] = 0;
res = strlen(name);
}
HeapFree( GetProcessHeap(), 0, nameW );
/* GetTextFaceA does NOT include the nul byte in the return count. */
} elsereturn res ? res - 1 : 0;
res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
- HeapFree( GetProcessHeap(), 0, nameW );
- return res;
return GetTextFaceW(hdc, 0, NULL);
}
This is wrong, you can't return the W length from the A function.