[PATCH 3/3] mpr: Implement WNetUseConnectionA(). (try 4)

Nikolay Sivov bunglehead at gmail.com
Sat Jan 23 07:00:49 CST 2016


On 23.01.2016 15:47, Pierre Schweitzer wrote:
> On 22/01/2016 09:58, Alexandre Julliard wrote:
>> Pierre Schweitzer <pierre at reactos.org> writes:
>>
>>> +    ret = WNetUseConnectionW(hwndOwner, pRes, passW, userIDW, dwFlags,
>>> +                             accessNameW, lpBufferSize, lpResult);
>>> +    if (lpAccessName && lpBufferSize && *lpBufferSize && accessNameW)
>>> +    {
>>> +        len = WideCharToMultiByte(CP_ACP, 0, accessNameW, -1, NULL, 0, NULL, NULL);
>>> +        if (len && len <= *lpBufferSize)
>>> +            WideCharToMultiByte(CP_ACP, 0, accessNameW, -1, lpAccessName, len, NULL, NULL);
>>> +    }
>>
>> You need to handle failures, and a possibly different lpBufferSize for
>> the W function. It could also use some test cases, which would probably
>> require the W function to do something useful first.
> 
> Thanks for your review.
> 
> There's no need, in my understanding of MSDN of a different
> lpBufferSize. It contains the size in chars of the buffer. So, be it for
> A or W, we pass the same,

That's a wrong assumption. In this case you need to get length of
W-buffer with WNetUseConnectionW() first, allocate buffer, call
WNetUseConnectionW(), then convert W->A and at this point
WideCharToMultiByte will return required A-buffer length that you can
compare with WNetUseConnectionA argument value to check if passed buffer
was large enough.



More information about the wine-devel mailing list