``` + if (request->device_info.flags & BDIF_NAME) + { + LoadStringA( instance, IDS_AUTH_WIZARD_NAMED_PAIR_REQUEST, format, sizeof( format ) ); + snprintf( msg, sizeof( msg ), format, request->device_info.name, request->numeric_value_or_passkey ); + } + else + { + LoadStringA( instance, IDS_AUTH_WIZARD_UNNAMED_PAIR_REQUEST, format, sizeof( format ) ); + snprintf( msg, sizeof( msg ), format, addr.rgBytes[0], addr.rgBytes[1], addr.rgBytes[2], addr.rgBytes[3], + addr.rgBytes[4], addr.rgBytes[5], request->numeric_value_or_passkey ); + } + LoadStringA( instance, IDS_AUTH_WIZARD_PAIR_REQUEST_TITLE, title, sizeof( title ) ); + ret = MessageBoxA( NULL, msg, title, MB_YESNO ); + if (!ret) + { + ERR("MessageBoxW failed: %lu\n", ret ); + goto done; + } ```
Usually we want to keep code in W instead of doing a conversion. (And you already have a reference to "MessageBoxW"...)
I'm also tempted to advocate for using FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE), although maybe it's debatable whether avoiding the statically sized buffer or using that function's peculiar printf is an advantage...