Commit ae147a5b authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

regedit: Output an error message and exit with error code zero instead of calling exit(1).

parent 7d0f2dec
......@@ -83,6 +83,23 @@ void __cdecl output_message(unsigned int id, ...)
__ms_va_end(va_args);
}
void __cdecl error_exit(unsigned int id, ...)
{
WCHAR fmt[1536];
__ms_va_list va_args;
if (!LoadStringW(GetModuleHandleW(NULL), id, fmt, sizeof(fmt)/sizeof(*fmt)))
{
WINE_FIXME("LoadString failed with %u\n", GetLastError());
return;
}
__ms_va_start(va_args, id);
output_formatstring(fmt, va_args);
__ms_va_end(va_args);
exit(0); /* regedit.exe always terminates with error code zero */
}
typedef enum {
ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
} REGEDIT_ACTION;
......@@ -147,8 +164,7 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i)
break;
}
default:
output_message(STRING_UNHANDLED_ACTION);
exit(1);
error_exit(STRING_UNHANDLED_ACTION);
break;
}
}
......@@ -184,8 +200,7 @@ BOOL ProcessCmdLine(WCHAR *cmdline)
switch (toupperW(argv[i][1]))
{
case '?':
output_message(STRING_USAGE);
exit(0);
error_exit(STRING_USAGE);
break;
case 'D':
action = ACTION_DELETE;
......@@ -204,8 +219,7 @@ BOOL ProcessCmdLine(WCHAR *cmdline)
break;
default:
output_message(STRING_INVALID_SWITCH, argv[i]);
output_message(STRING_HELP);
exit(1);
error_exit(STRING_HELP);
}
}
......@@ -221,8 +235,7 @@ BOOL ProcessCmdLine(WCHAR *cmdline)
output_message(STRING_NO_REG_KEY);
break;
}
output_message(STRING_HELP);
exit(1);
error_exit(STRING_HELP);
}
for (; i < argc; i++)
......
......@@ -1421,8 +1421,7 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
file = _wfopen(file_name, wb_mode);
if (!file) {
_wperror(regedit);
output_message(STRING_CANNOT_OPEN_FILE, file_name);
exit(1);
error_exit(STRING_CANNOT_OPEN_FILE, file_name);
}
}
if(unicode)
......@@ -1478,10 +1477,9 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
lstrcpyW(reg_key_name_buf, reg_key_name);
/* open the specified key */
if (!(reg_key_class = parse_key_name(reg_key_name, &branch_name))) {
output_message(STRING_INCORRECT_REG_CLASS, reg_key_name);
exit(1);
}
if (!(reg_key_class = parse_key_name(reg_key_name, &branch_name)))
error_exit(STRING_INCORRECT_REG_CLASS, reg_key_name);
if (!branch_name || !*branch_name) {
/* no branch - registry class is specified */
file = REGPROC_open_export_file(file_name, unicode);
......@@ -1591,14 +1589,11 @@ void delete_registry_key(WCHAR *reg_key_name)
if (!reg_key_name || !reg_key_name[0])
return;
if (!(key_class = parse_key_name(reg_key_name, &key_name))) {
output_message(STRING_INCORRECT_REG_CLASS, reg_key_name);
exit(1);
}
if (!*key_name) {
output_message(STRING_DELETE_REG_CLASS_FAILED, reg_key_name);
exit(1);
}
if (!(key_class = parse_key_name(reg_key_name, &key_name)))
error_exit(STRING_INCORRECT_REG_CLASS, reg_key_name);
if (!*key_name)
error_exit(STRING_DELETE_REG_CLASS_FAILED, reg_key_name);
RegDeleteTreeW(key_class, key_name);
}
......@@ -34,6 +34,7 @@ if (!(p)) \
}
void __cdecl output_message(unsigned int id, ...);
void __cdecl error_exit(unsigned int id, ...);
BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format);
BOOL import_registry_file(FILE *in);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment