1. Allow export_key() to return TRUE. 2. Append '.reg' file extension if necessary.
From: Hugh McMaster hugh.mcmaster@outlook.com
We don't handle errors in export_registry_data() anyway.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54491 --- programs/regedit/framewnd.c | 2 +- programs/regedit/regproc.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index d821d4dad77..3bc60ee0f75 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -500,7 +500,7 @@ static BOOL ExportRegistryFile(HWND hWnd) BOOL result; result = export_registry_key(ofn.lpstrFile, (LPWSTR)ofn.lCustData, ofn.nFilterIndex); if (!result) { - /*printf("Can't open file "%s"\n", ofn.lpstrFile);*/ + FIXME("Registry export failed.\n"); return FALSE; } } else { diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index 4f84c5883be..30106380241 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -1328,7 +1328,7 @@ static void export_key_name(FILE *fp, WCHAR *name, BOOL unicode)
#define MAX_SUBKEY_LEN 257
-static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode) +static void export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode) { LONG rc; DWORD max_value_len = 256, value_len; @@ -1398,7 +1398,6 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode) }
free(subkey_name); - return 0; }
static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode) @@ -1450,7 +1449,6 @@ static BOOL export_key(WCHAR *file_name, WCHAR *path, BOOL unicode) HKEY key_class, key; WCHAR *subkey; FILE *fp; - BOOL ret;
if (!(key_class = parse_key_name(path, &subkey))) { @@ -1463,12 +1461,12 @@ static BOOL export_key(WCHAR *file_name, WCHAR *path, BOOL unicode) return FALSE;
fp = REGPROC_open_export_file(file_name, unicode); - ret = export_registry_data(fp, key, path, unicode); + export_registry_data(fp, key, path, unicode); export_newline(fp, unicode); fclose(fp);
RegCloseKey(key); - return ret; + return TRUE; }
static BOOL export_all(WCHAR *file_name, WCHAR *path, BOOL unicode)
From: Hugh McMaster hugh.mcmaster@outlook.com
--- programs/regedit/framewnd.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index 3bc60ee0f75..c2af414d268 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -493,6 +493,7 @@ static BOOL ExportRegistryFile(HWND hWnd) InitOpenFileName(hWnd, &ofn); LoadStringW(hInst, IDS_FILEDIALOG_EXPORT_TITLE, title, ARRAY_SIZE(title)); ofn.lpstrTitle = title; + ofn.lpstrDefExt = L"reg"; ofn.Flags = OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; ofn.lpfnHook = ExportRegistryFile_OFNHookProc; ofn.lpTemplateName = MAKEINTRESOURCEW(IDD_EXPORT_TEMPLATE);