"Mike McCormack" <mike(a)codeweavers.com> wrote:
> -HDC WINAPI CreateMetaFileW(LPCWSTR filename)
> +HDC WINAPI CreateMetaFileA(LPCSTR filename)
> {
> - LPSTR filenameA;
> + LPWSTR filenameW;
> DWORD len;
> HDC hReturnDC;
>
> - if (!filename) return CreateMetaFileA(NULL);
> + if (!filename) return CreateMetaFileW(NULL);
>
> - len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
> - filenameA = HeapAlloc( GetProcessHeap(), 0, len );
> - WideCharToMultiByte( CP_ACP, 0, filename, -1, filenameA, len, NULL, NULL );
> + len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
> + filenameW = HeapAlloc( GetProcessHeap(), 0, len );
> + MultiByteToWideChar( CP_ACP, 0, filename, -1, filenameW, len );
MultiByteToWideChar returns number of characters, not bytes. You have
to allocate len * sizeof(WCHAR) bytes.
--
Dmitry.