mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[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
This commit is contained in:
parent
fea414b9ed
commit
be8a6f8af1
2 changed files with 30 additions and 3 deletions
|
@ -37,9 +37,7 @@ static void output_writeconsole(const WCHAR *str, DWORD wlen)
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
/* This is win32gui application, don't ever try writing to console.
|
/* This is win32gui application, don't ever try writing to console.
|
||||||
* For the console version we have a separate reg.exe application. */
|
* For the console version we have a separate reg.exe application. */
|
||||||
WCHAR AppStr[255];
|
MessageBoxW(NULL, str, NULL, MB_ICONERROR);
|
||||||
LoadStringW(hInst, IDS_APP_TITLE, AppStr, ARRAY_SIZE(AppStr));
|
|
||||||
MessageBoxW(NULL, str, AppStr, MB_OK | MB_ICONINFORMATION);
|
|
||||||
#else
|
#else
|
||||||
DWORD count;
|
DWORD count;
|
||||||
|
|
||||||
|
@ -219,7 +217,11 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
output_message(STRING_UNHANDLED_ACTION);
|
||||||
|
#else
|
||||||
error_exit(STRING_UNHANDLED_ACTION);
|
error_exit(STRING_UNHANDLED_ACTION);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_class = parse_key_name(reg_key_name, &key_name)))
|
||||||
{
|
{
|
||||||
if (key_name) *(key_name - 1) = 0;
|
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);
|
error_exit(STRING_INVALID_SYSTEM_KEY, reg_key_name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!key_name || !*key_name)
|
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);
|
error_exit(STRING_DELETE_FAILED, reg_key_name);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
SHDeleteKey(key_class, key_name);
|
SHDeleteKey(key_class, key_name);
|
||||||
|
@ -1460,7 +1472,12 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
_wperror(L"regedit");
|
_wperror(L"regedit");
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
output_message(STRING_CANNOT_OPEN_FILE, file_name);
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
error_exit(STRING_CANNOT_OPEN_FILE, file_name);
|
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;
|
return FALSE;
|
||||||
|
|
||||||
fp = REGPROC_open_export_file(file_name, unicode);
|
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_registry_data(fp, key, path, unicode);
|
||||||
export_newline(fp, unicode);
|
export_newline(fp, unicode);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -1522,6 +1543,10 @@ static BOOL export_all(WCHAR *file_name, WCHAR *path, BOOL unicode)
|
||||||
WCHAR *class_name;
|
WCHAR *class_name;
|
||||||
|
|
||||||
fp = REGPROC_open_export_file(file_name, unicode);
|
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++)
|
for (i = 0; i < ARRAY_SIZE(classes); i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue