Dmitry Timoshkov wrote: > "Nikolay Sivov" <[EMAIL PROTECTED]> wrote: > >>>> LoadStringA doesn't return necessary buffer length when called with >>>> (buflen = 0) but LoadStringW does. >>>> Since I need to return a necessary buffer length from both >>>> GetRoleText[A/W] I used LoadStringW in both cases, >>>> converting to multibyte in ansi call. >>> >>> I don't see in your tests that GetRoleText is supposed to return the >>> string >>> length when it's called with buffer length set to 0. >>> >> GetRoleText supposed to return string length when buffer is NULL. >> Cause there's no way to get this length by LoadStringA *without* >> passing a not-NULL pointer to buffer (I don't now how long should >> it be) so I used LoadStringW for ansi call too. > > Again, I don't see in your tests that GetRoleText is supposed > to return the string length when it's called with buffer length > set to 0. > I've made these tests but I still don't follow you: - GetRoleTextW returns length when called with NULL buffer (and zero or not-zero buflen) - GetRoleTextA returns length only when called with NULL buffer. On zero buflen it returns 0.
As I understood you want to use LoadStringA in GetRoleTextA and remove all wide->mb conversions. But: there are 3 last lines of LoadStringA: --- buffer[retval] = 0; TRACE("returning %s\n", debugstr_a(buffer)); return retval; --- It's the only place when length is returned. So it will always write to buffer => I can't get a length with it without writing. And it doesn't matter that GetRoleTextA returns 0 on buflen = 0 cause behavior on NULL buffer still different between LoadStringA (will crash) and LoadStringW (will return length).