regedit: adding confirmation message before importing from file
Nowres Rafid
nowres.rafed at gmail.com
Tue Aug 16 17:06:00 CDT 2011
---
programs/regedit/regedit.c | 32 ++++++++++++++++++++++++++++----
programs/regedit/regedit.rc | 7 +++++++
programs/regedit/resource.h | 3 +++
3 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/programs/regedit/regedit.c b/programs/regedit/regedit.c
index cc0fc3a..9b70bfe 100644
--- a/programs/regedit/regedit.c
+++ b/programs/regedit/regedit.c
@@ -18,10 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <ctype.h>
-#include <stdio.h>
#include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include "resource.h"
#include "regproc.h"
+#include "wine/unicode.h"
static const char *usage =
"Usage:\n"
@@ -142,6 +146,7 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
if (strcmp(filename, "-") == 0)
{
reg_file = stdin;
+ import_registry_file(reg_file);
}
else
{
@@ -159,15 +164,34 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
getAppName(), filename, GetLastError());
exit(1);
}
- reg_file = fopen(realname, "r");
+
+ reg_file = fopen(realname, "r");
if (reg_file == NULL)
{
perror("");
fprintf(stderr, "%s: Can't open file \"%s\"\n", getAppName(), filename);
exit(1);
}
+
+ if (MessageBoxW(NULL, MAKEINTRESOURCEW(IDS_IMPORT_BOX_TEXT),
+ MAKEINTRESOURCEW(IDS_APP_TITLE),
+ MB_YESNO | MB_ICONEXCLAMATION) == IDYES)
+ {
+ if (import_registry_file(reg_file))
+ {
+ MessageBoxW(NULL, MAKEINTRESOURCEW(IDS_IMPORT_SUCCESS_BOX_TEXT),
+ MAKEINTRESOURCEW(IDS_APP_TITLE),
+ MB_OK | MB_ICONINFORMATION);
+ }
+ else
+ {
+ MessageBoxW(NULL, MAKEINTRESOURCEW(IDS_IMPORT_FAIL_BOX_TEXT),
+ MAKEINTRESOURCEW(IDS_APP_TITLE),
+ MB_OK | MB_ICONERROR);
+ }
+ }
}
- import_registry_file(reg_file);
+
if (realname)
{
HeapFree(GetProcessHeap(),0,realname);
diff --git a/programs/regedit/regedit.rc b/programs/regedit/regedit.rc
index 8d3b333..0c3fd10 100644
--- a/programs/regedit/regedit.rc
+++ b/programs/regedit/regedit.rc
@@ -188,6 +188,13 @@ END
STRINGTABLE
BEGIN
+ IDS_IMPORT_BOX_TEXT "Are you sure you want to add file informations to the registry?"
+ IDS_IMPORT_SUCCESS_BOX_TEXT "Values successfuly added to the registry"
+ IDS_IMPORT_FAIL_BOX_TEXT "Failed to add values to the registry"
+END
+
+STRINGTABLE
+BEGIN
IDS_FILEDIALOG_IMPORT_TITLE "Import Registry File"
IDS_FILEDIALOG_EXPORT_TITLE "Export Registry File"
IDS_FILEDIALOG_FILTER_REG "Registry files (*.reg)"
diff --git a/programs/regedit/resource.h b/programs/regedit/resource.h
index 020765e..f9854e2 100644
--- a/programs/regedit/resource.h
+++ b/programs/regedit/resource.h
@@ -58,6 +58,9 @@
#define IDS_REGISTRY_VALUE_NOT_SET 162
#define IDS_REGISTRY_VALUE_CANT_DISPLAY 164
#define IDS_REGISTRY_UNKNOWN_TYPE 165
+#define IDS_IMPORT_BOX_TEXT 304
+#define IDS_IMPORT_SUCCESS_BOX_TEXT 305
+#define IDS_IMPORT_FAIL_BOX_TEXT 306
#define IDC_LICENSE_EDIT 1029
#define ID_REGISTRY_EXIT 32770
#define ID_FAVORITES_ADDTOFAVORITES 32772
--
1.7.4.1
--------------060806000407070608070504--
More information about the wine-patches
mailing list