From 9c65d13514adf59f5e13fc87e094d2c083721633 Mon Sep 17 00:00:00 2001 From: pit-ray Date: Tue, 13 Feb 2024 12:26:32 +0900 Subject: [PATCH] fix count of wmemcpy --- include/fluent_tray.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/fluent_tray.hpp b/include/fluent_tray.hpp index cc9a94f..dda5bad 100644 --- a/include/fluent_tray.hpp +++ b/include/fluent_tray.hpp @@ -1180,10 +1180,10 @@ namespace fluent_tray LONG font_size=0, LONG font_weight=0, const std::string& font_name="") { - NONCLIENTMETRICS metrics ; + NONCLIENTMETRICSW metrics ; metrics.cbSize = sizeof(metrics) ; - if(!SystemParametersInfo( + if(!SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0)) { return false ; @@ -1208,14 +1208,16 @@ namespace fluent_tray if(!util::string2wstring(font_name, font_name_wide)) { return false ; } - auto dst = logfont.lfFaceName ; + auto& dst = logfont.lfFaceName ; if(font_name_wide.size() < LF_FACESIZE) { - std::wmemcpy(dst, font_name_wide.c_str(), sizeof(WCHAR) * font_name_wide.length()) ; + std::wmemcpy( + dst, font_name_wide.c_str(), font_name_wide.length()) ; dst[font_name_wide.size()] = L'\0' ; } else { - std::wmemcpy(dst, font_name_wide.c_str(), sizeof(WCHAR) * (LF_FACESIZE - 1)) ; + std::wmemcpy( + dst, font_name_wide.c_str(), LF_FACESIZE - 1) ; dst[LF_FACESIZE - 1] = L'\0' ; } }