/*
* Windows regedit.exe registry editor implementation.
*
- * Copyright 2002 Andriy Palamarchuk
+ * Copyright (C) 2002 Andriy Palamarchuk
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
pos++;
}
}
- memcpy(file_name, *command_line, pos * sizeof((*command_line)[0]));
+ memcpy(file_name, *command_line, pos * sizeof(WCHAR));
/* remove the last backslash */
if (file_name[pos - 1] == L'\\')
{
(*command_line) += pos;
}
-BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s)
+BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s, BOOL silent)
{
+ TCHAR szTitle[256], szText[256];
switch (action)
{
case ACTION_ADD:
}
import_registry_file(fp);
get_file_name(&s, filename);
+ LoadString(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
+ LoadString(hInst, IDS_IMPORT_OK, szText, COUNT_OF(szText));
+ /* show successful import */
+ if (!silent)
+ MessageBox(NULL, szText, szTitle, MB_OK);
}
break;
}
BOOL ProcessCmdLine(LPWSTR lpCmdLine)
{
+ BOOL silent = FALSE;
REGEDIT_ACTION action = ACTION_UNDEF;
LPWSTR s = lpCmdLine; /* command line pointer */
WCHAR ch = *s; /* current character */
chu = (WCHAR)towupper(ch);
if (!ch2 || iswspace(ch2))
{
- if (chu == L'S' || chu == L'V')
+ if (chu == L'S')
{
- /* ignore these switches */
+ /* Silence dialogs */
+ silent = TRUE;
+ }
+ else if (chu == L'V')
+ {
+ /* Ignore this switch */
}
else
{
}
if (*s && action == ACTION_UNDEF)
- action = ACTION_ADD;
-
+ {
+ if (!silent)
+ {
+ TCHAR szTitle[256], szText[256];
+ LoadString(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
+ LoadString(hInst, IDS_IMPORT_PROMPT, szText, COUNT_OF(szText));
+ /* request import confirmation */
+ if (MessageBox(NULL, szText, szTitle, MB_YESNO) == IDYES)
+ action = ACTION_ADD;
+ else
+ return TRUE;
+ }
+ else
+ {
+ action = ACTION_ADD;
+ }
+ }
if (action == ACTION_UNDEF)
return FALSE;
- return PerformRegAction(action, s);
+ return PerformRegAction(action, s, silent);
}