[ros-dev] [ros-diffs] [hbelusca] 72943: [PING] - Use a dynamic-allocated buffer with FormatMessageW, fixes messages disappearance (eg. ping help in russian). CORE-12108 #comment Fixed in r72943. - Remove the unneeded 1-...
Mark Jansen
learn0more+ros at gmail.com
Sun Oct 9 12:03:34 UTC 2016
Be careful with that, they do not have to be null-terminated!
the return value will give you the length in this case.
On Sun, Oct 9, 2016 at 9:45 AM, Colin Finck <colin at reactos.org> wrote:
> hbelusca at svn.reactos.org wrote:
> > +#define RC_STRING_MAX_SIZE 4096
> > +
> > + WCHAR Format[RC_STRING_MAX_SIZE];
> > + LPWSTR lpMsgBuf = NULL;
> > + DWORD Len;
> > va_list args;
> >
> > if (!LoadStringW(GetModuleHandleW(NULL), id, Format,
> > _countof(Format)))
>
> Now instead of
>
> #define RC_STRING_MAX_SIZE 4096
> WCHAR Format[RC_STRING_MAX_SIZE];
> LoadStringW(GetModuleHandleW(NULL), id, Format, _countof(Format));
>
> just do a
>
> LPWSTR lpFormatBuf;
> LoadStringW(GetModuleHandleW(NULL), id, (LPWSTR)&lpFormatBuf, 0);
>
> and you have a perfect universal solution for any resource string length
> without caring about buffer sizes at all. It doesn't even need any extra
> memory :)
> This should actually be changed in a lot of places!
>
>
> - Colin
>
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.reactos.org/pipermail/ros-dev/attachments/20161009/1cf51e27/attachment.html>
More information about the Ros-dev
mailing list