"Benjamin Arai" me@benjaminarai.com writes:
- str = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*size);
- if (!str)
- return E_OUTOFMEMORY;
- size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, str, size);
- if (!size) {
- ERR("GetLocaleInfo of 0x%lx failed in 2nd stage?!\n", localeValue);
- HeapFree(GetProcessHeap(),0,str);
- return HRESULT_FROM_WIN32(GetLastError());
- }
- *pbstrOut = SysAllocString(str);
You should do the GetLocaleInfoW directly into the destination string instead of allocating another buffer.