On Tuesday, 7 July 2015, 10:31 pm UTC+10, Nikolay Sivov wrote:

>On 07.07.2015 11:15, Alistair Leslie-Hughes wrote: > >> + retval = heap_alloc(cbRetBuffer*sizeof(WCHAR)); >> + >> + ret = SQLGetPrivateProfileStringW(sect, entry, string, retval, cbRetBuffer, file); > >cbRetBuffer is A-buffer length, you're still using it as W-buffer length.

Unless I'm reading MSDN [1] incorrectly, this should work.

cbRetBuffer is the size, in characters, of RetBuffer (i.e. the A-buffer).

retval is the W-buffer. Its allocated byte size is double that of RetBuffer,
but its size, in characters, is still the same.