[resend 1/8] reg: Add system error printing function

Alexandre Julliard julliard at winehq.org
Tue Feb 17 03:56:40 CST 2015


Jonathan Vollebregt <jnvsor at gmail.com> writes:

> +static void reg_print_error(LSTATUS error_code)
> +{
> +    switch (error_code)
> +    {
> +        case ERROR_SUCCESS:
> +            return;
> +        case ERROR_BAD_COMMAND:
> +            reg_message(STRING_INVALID_CMDLINE);
> +            return;
> +        default:
> +        {
> +            static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
> +            WCHAR *message = NULL;
> +            FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
> +                NULL, error_code, 0, (WCHAR *)&message, 0, NULL);
> +
> +            reg_message(STRING_ERROR);
> +            reg_printfW(error_string, error_code, message);
> +            LocalFree(message);
> +            return;
> +        }
> +    }
> +}

I don't think that's an improvement. There may be a need for generic
Win32 error printing through FormatMessage for unknown codes, but I
don't see why you'd want to route all errors through it. In particular,
having to make up your own Win32 error codes only to convert them back
to string ids is quite ugly.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list