On Fri May 2 18:28:11 2025 +0000, Elizabeth Figura wrote:
+ 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...
Change to using the W variants, thanks.
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...
I'm okay with it, but we'll need to add an extra function that only gets used once. Maybe we could use it once I implement `BluetoothSelectDevices` as well?