https://git.reactos.org/?p=reactos.git;a=commitdiff;h=be8a6f8af19b7b9f7be29…
commit be8a6f8af19b7b9f7be29ea6b81ed8da029daa2c
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Oct 26 19:57:42 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Oct 26 19:57:42 2023 +0900
[REGEDIT] Improve error handling (#5833)
- Don't exit the main program on error.
- Improve output_message function.
- Use output_message instead of some
error_exit function calls.
CORE-19188
---
base/applications/regedit/regedit.c | 8 +++++---
base/applications/regedit/regproc.c | 25 +++++++++++++++++++++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/base/applications/regedit/regedit.c b/base/applications/regedit/regedit.c
index 35fa13f037d..0e3cc27f669 100644
--- a/base/applications/regedit/regedit.c
+++ b/base/applications/regedit/regedit.c
@@ -37,9 +37,7 @@ static void output_writeconsole(const WCHAR *str, DWORD wlen)
#ifdef __REACTOS__
/* This is win32gui application, don't ever try writing to console.
* For the console version we have a separate reg.exe application. */
- WCHAR AppStr[255];
- LoadStringW(hInst, IDS_APP_TITLE, AppStr, ARRAY_SIZE(AppStr));
- MessageBoxW(NULL, str, AppStr, MB_OK | MB_ICONINFORMATION);
+ MessageBoxW(NULL, str, NULL, MB_ICONERROR);
#else
DWORD count;
@@ -219,7 +217,11 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int
*i)
break;
}
default:
+#ifdef __REACTOS__
+ output_message(STRING_UNHANDLED_ACTION);
+#else
error_exit(STRING_UNHANDLED_ACTION);
+#endif
break;
}
}
diff --git a/base/applications/regedit/regproc.c b/base/applications/regedit/regproc.c
index f140b672381..1ef1fc9e6c2 100644
--- a/base/applications/regedit/regproc.c
+++ b/base/applications/regedit/regproc.c
@@ -1105,11 +1105,23 @@ void delete_registry_key(WCHAR *reg_key_name)
if (!(key_class = parse_key_name(reg_key_name, &key_name)))
{
if (key_name) *(key_name - 1) = 0;
+#ifdef __REACTOS__
+ output_message(STRING_INVALID_SYSTEM_KEY, reg_key_name);
+ return;
+#else
error_exit(STRING_INVALID_SYSTEM_KEY, reg_key_name);
+#endif
}
if (!key_name || !*key_name)
+#ifdef __REACTOS__
+ {
+ output_message(STRING_DELETE_FAILED, reg_key_name);
+ return;
+ }
+#else
error_exit(STRING_DELETE_FAILED, reg_key_name);
+#endif
#ifdef __REACTOS__
SHDeleteKey(key_class, key_name);
@@ -1460,7 +1472,12 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL
unicode)
if (!file)
{
_wperror(L"regedit");
+#ifdef __REACTOS__
+ output_message(STRING_CANNOT_OPEN_FILE, file_name);
+ return NULL;
+#else
error_exit(STRING_CANNOT_OPEN_FILE, file_name);
+#endif
}
}
@@ -1506,6 +1523,10 @@ static BOOL export_key(WCHAR *file_name, WCHAR *path, BOOL
unicode)
return FALSE;
fp = REGPROC_open_export_file(file_name, unicode);
+#ifdef __REACTOS__
+ if (!fp)
+ return TRUE; /* Error message is already displayed */
+#endif
export_registry_data(fp, key, path, unicode);
export_newline(fp, unicode);
fclose(fp);
@@ -1522,6 +1543,10 @@ static BOOL export_all(WCHAR *file_name, WCHAR *path, BOOL
unicode)
WCHAR *class_name;
fp = REGPROC_open_export_file(file_name, unicode);
+#ifdef __REACTOS__
+ if (!fp)
+ return TRUE; /* Error message is already displayed */
+#endif
for (i = 0; i < ARRAY_SIZE(classes); i++)
{