[PATCH 2/7] regedit: Use FormatMessage() for optimal memory usage (v2)
Hugh McMaster
hugh.mcmaster at outlook.com
Tue Jan 31 05:55:16 CST 2017
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/regedit/edit.c | 14 +++++++++-----
programs/regedit/regedit.rc | 12 ++++++------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c
index a223535..3f2b7a4 100644
--- a/programs/regedit/edit.c
+++ b/programs/regedit/edit.c
@@ -49,15 +49,19 @@ struct edit_params
static INT vmessagebox(HWND hwnd, INT buttons, INT titleId, INT resId, va_list ap)
{
WCHAR title[256];
- WCHAR errfmt[1024];
- WCHAR errstr[1024];
+ WCHAR fmt[1024];
+ WCHAR *str;
+ int ret;
LoadStringW(hInst, titleId, title, COUNT_OF(title));
- LoadStringW(hInst, resId, errfmt, COUNT_OF(errfmt));
+ LoadStringW(hInst, resId, fmt, COUNT_OF(fmt));
- vsnprintfW(errstr, COUNT_OF(errstr), errfmt, ap);
+ FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ fmt, 0, 0, (WCHAR *)&str, 0, &ap);
+ ret = MessageBoxW(hwnd, str, title, buttons);
+ LocalFree(str);
- return MessageBoxW(hwnd, errstr, title, buttons);
+ return ret;
}
static INT messagebox(HWND hwnd, INT buttons, INT titleId, INT resId, ...)
diff --git a/programs/regedit/regedit.rc b/programs/regedit/regedit.rc
index 072648e..51c4b11 100644
--- a/programs/regedit/regedit.rc
+++ b/programs/regedit/regedit.rc
@@ -176,16 +176,16 @@ END
STRINGTABLE
BEGIN
IDS_ERROR "Error"
- IDS_BAD_KEY "Can't query key '%s'"
- IDS_BAD_VALUE "Can't query value '%s'"
- IDS_UNSUPPORTED_TYPE "Can't edit keys of this type (%u)"
- IDS_TOO_BIG_VALUE "Value is too big (%u)"
+ IDS_BAD_KEY "Unable to query the registry key '%1'."
+ IDS_BAD_VALUE "Unable to query the registry value '%1'."
+ IDS_UNSUPPORTED_TYPE "Unable to edit registry keys of this type (%1!u!)."
+ IDS_TOO_BIG_VALUE "The value is too big (%1!u!)."
IDS_DELETE_BOX_TITLE "Confirm Value Delete"
- IDS_DELETE_BOX_TEXT "Are you sure you want to delete value '%s'?"
+ IDS_DELETE_BOX_TEXT "Are you sure you want to delete the registry value '%1'?"
IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?"
IDS_NEWKEY "New Key #%d"
IDS_NEWVALUE "New Value #%d"
- IDS_NOTFOUND "Search string '%s' not found"
+ IDS_NOTFOUND "The search string '%1' was not found."
END
STRINGTABLE
--
2.7.4
More information about the wine-patches
mailing list