[PATCH 1/7] regedit: Use a helper for LoadString() and add debug information
Hugh McMaster
hugh.mcmaster at outlook.com
Sun Jan 29 05:56:49 CST 2017
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/regedit/edit.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c
index e211ff8..80477e0 100644
--- a/programs/regedit/edit.c
+++ b/programs/regedit/edit.c
@@ -30,10 +30,13 @@
#include <shlwapi.h>
#include "wine/unicode.h"
+#include "wine/debug.h"
#include "main.h"
#include "regproc.h"
#include "resource.h"
+WINE_DEFAULT_DEBUG_CHANNEL(regedit);
+
static const WCHAR* editValueName;
static WCHAR* stringValueData;
static BOOL isDecimal;
@@ -46,17 +49,27 @@ struct edit_params
LONG cbData;
};
-static INT vmessagebox(HWND hwnd, INT buttons, INT titleId, INT resId, va_list ap)
+static void load_string(unsigned int msg_id, WCHAR *buf, unsigned int count)
{
static const WCHAR errorW[] = {'E','r','r','o','r',0};
- static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',' ','e','r','r','o','r',' ','s','t','r','i','n','g','!',0};
+ if (!buf) return;
+
+ if (!LoadStringW(hInst, msg_id, buf, count))
+ {
+ WINE_FIXME("LoadString failed with %u\n", GetLastError());
+ lstrcpyW(buf, errorW);
+ }
+}
+
+static INT vmessagebox(HWND hwnd, INT buttons, INT titleId, INT resId, va_list ap)
+{
WCHAR title[256];
WCHAR errfmt[1024];
WCHAR errstr[1024];
- if (!LoadStringW(hInst, titleId, title, COUNT_OF(title))) lstrcpyW(title, errorW);
- if (!LoadStringW(hInst, resId, errfmt, COUNT_OF(errfmt))) lstrcpyW(errfmt, unknownW);
+ load_string(titleId, title, COUNT_OF(title));
+ load_string(resId, errfmt, COUNT_OF(errfmt));
vsnprintfW(errstr, COUNT_OF(errstr), errfmt, ap);
@@ -90,10 +103,8 @@ static void error_code_messagebox(HWND hwnd, DWORD error_code)
DWORD status;
WCHAR title[256];
static WCHAR fallback[] = {'E','r','r','o','r',' ','d','i','s','p','l','a','y','i','n','g',' ','e','r','r','o','r',' ','m','e','s','s','a','g','e','.','\n',0};
- static const WCHAR title_error[] = {'E','r','r','o','r',0};
- if (!LoadStringW(hInst, IDS_ERROR, title, COUNT_OF(title)))
- lstrcpyW(title, title_error);
+ load_string(IDS_ERROR, title, COUNT_OF(title));
status = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error_code, 0, (LPWSTR)&lpMsgBuf, 0, NULL);
if (!status)
--
2.7.4
More information about the wine-patches
mailing list