regedit: Use a separate dialog proc function for string data types.
[wine.git] / programs / regedit / edit.c
blobd668425b137113964ee634d3215b2f990ae8cce1
1 /*
2 * Registry editing UI functions.
4 * Copyright (C) 2003 Dimitrie O. Paun
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
23 #include <windows.h>
24 #include <commctrl.h>
25 #include <commdlg.h>
26 #include <cderr.h>
27 #include <shellapi.h>
28 #include <shlwapi.h>
30 #include "main.h"
32 static const WCHAR* editValueName;
33 static WCHAR* stringValueData;
34 static BOOL isDecimal;
36 struct edit_params
38 HKEY hkey;
39 const WCHAR *value_name;
40 DWORD type;
41 void *data;
42 DWORD size;
45 static int vmessagebox(HWND hwnd, int buttons, int titleId, int resId, va_list va_args)
47 WCHAR title[256];
48 WCHAR fmt[1024];
49 WCHAR *str;
50 int ret;
52 LoadStringW(hInst, titleId, title, ARRAY_SIZE(title));
53 LoadStringW(hInst, resId, fmt, ARRAY_SIZE(fmt));
55 FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER,
56 fmt, 0, 0, (WCHAR *)&str, 0, &va_args);
57 ret = MessageBoxW(hwnd, str, title, buttons);
58 LocalFree(str);
60 return ret;
63 int WINAPIV messagebox(HWND hwnd, int buttons, int titleId, int resId, ...)
65 va_list ap;
66 INT result;
68 va_start(ap, resId);
69 result = vmessagebox(hwnd, buttons, titleId, resId, ap);
70 va_end(ap);
72 return result;
75 static void WINAPIV error_code_messagebox(HWND hwnd, unsigned int msg_id, ...)
77 va_list ap;
79 va_start(ap, msg_id);
80 vmessagebox(hwnd, MB_OK|MB_ICONERROR, IDS_ERROR, msg_id, ap);
81 va_end(ap);
84 static INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT msg, WPARAM wparam, LPARAM lparam)
86 HWND hwndValue;
87 unsigned int len;
89 switch (msg)
91 case WM_INITDIALOG:
92 SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, editValueName);
93 SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, stringValueData);
94 return TRUE;
95 case WM_COMMAND:
96 switch (LOWORD(wparam))
98 case IDOK:
99 hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA);
100 len = GetWindowTextLengthW(hwndValue);
101 stringValueData = realloc(stringValueData, (len + 1) * sizeof(WCHAR));
102 if (!GetWindowTextW(hwndValue, stringValueData, len + 1))
103 *stringValueData = 0;
104 /* fall through */
105 case IDCANCEL:
106 EndDialog(hwndDlg, wparam);
107 return TRUE;
110 return FALSE;
113 static BOOL change_dword_base(HWND hwndDlg, BOOL toHex)
115 WCHAR buf[128];
116 UINT64 val;
118 if (!GetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf, ARRAY_SIZE(buf))) return FALSE;
119 if (!swscanf(buf, toHex ? L"%I64u" : L"%I64x", &val)) return FALSE;
120 wsprintfW(buf, toHex ? L"%I64x" : L"%I64u", val);
121 return SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf);
124 static INT_PTR CALLBACK modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
126 HWND hwndValue;
127 WCHAR buff[64];
128 int len;
130 switch(uMsg) {
131 case WM_INITDIALOG:
132 SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, editValueName);
133 SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, stringValueData);
134 CheckRadioButton(hwndDlg, IDC_DWORD_HEX, IDC_DWORD_DEC, IDC_DWORD_HEX);
135 isDecimal = FALSE;
136 if (lParam == REG_QWORD && LoadStringW(GetModuleHandleW(0), IDS_EDIT_QWORD, buff, ARRAY_SIZE(buff)))
137 SetWindowTextW(hwndDlg, buff);
138 return TRUE;
139 case WM_COMMAND:
140 switch (LOWORD(wParam)) {
141 case IDC_DWORD_HEX:
142 if (isDecimal && change_dword_base(hwndDlg, TRUE)) isDecimal = FALSE;
143 break;
144 case IDC_DWORD_DEC:
145 if (!isDecimal && change_dword_base(hwndDlg, FALSE)) isDecimal = TRUE;
146 break;
147 case IDOK:
148 if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) {
149 len = GetWindowTextLengthW(hwndValue);
150 stringValueData = realloc(stringValueData, (len + 1) * sizeof(WCHAR));
151 if (!GetWindowTextW(hwndValue, stringValueData, len + 1))
152 *stringValueData = 0;
154 /* Fall through */
155 case IDCANCEL:
156 EndDialog(hwndDlg, wParam);
157 return TRUE;
160 return FALSE;
163 static INT_PTR CALLBACK bin_modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
165 struct edit_params *params;
166 BYTE *data;
167 LONG size;
168 LONG lRet;
170 switch(uMsg) {
171 case WM_INITDIALOG:
172 params = (struct edit_params *)lParam;
173 SetWindowLongPtrW(hwndDlg, DWLP_USER, (ULONG_PTR)params);
174 if (params->value_name)
175 SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, params->value_name);
176 else
177 SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, g_pszDefaultValueName);
178 SendDlgItemMessageW(hwndDlg, IDC_VALUE_DATA, HEM_SETDATA, (WPARAM)params->size, (LPARAM)params->data);
179 SendDlgItemMessageW(hwndDlg, IDC_VALUE_DATA, WM_SETFONT, (WPARAM) GetStockObject(ANSI_FIXED_FONT), TRUE);
180 return TRUE;
181 case WM_COMMAND:
182 switch (LOWORD(wParam)) {
183 case IDOK:
184 params = (struct edit_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
185 size = SendDlgItemMessageW(hwndDlg, IDC_VALUE_DATA, HEM_GETDATA, 0, 0);
186 data = malloc(size);
188 SendDlgItemMessageW(hwndDlg, IDC_VALUE_DATA, HEM_GETDATA, (WPARAM)size, (LPARAM)data);
189 lRet = RegSetValueExW(params->hkey, params->value_name, 0, params->type, data, size);
190 free(data);
192 if (lRet == ERROR_SUCCESS)
193 EndDialog(hwndDlg, 1);
194 else
196 error_code_messagebox(hwndDlg, IDS_SET_VALUE_FAILED);
197 EndDialog(hwndDlg, 0);
199 return TRUE;
200 case IDCANCEL:
201 EndDialog(hwndDlg, 0);
202 return TRUE;
205 return FALSE;
208 static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType, LONG *len)
210 DWORD valueDataLen;
211 LPWSTR buffer = NULL;
212 LONG lRet;
214 lRet = RegQueryValueExW(hKey, valueName, NULL, lpType, NULL, &valueDataLen);
215 if (lRet) {
216 if (lRet == ERROR_FILE_NOT_FOUND && !valueName) { /* no default value here, make it up */
217 if (len) *len = 1;
218 if (lpType) *lpType = REG_SZ;
219 buffer = malloc(sizeof(WCHAR));
220 *buffer = '\0';
221 return buffer;
223 error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName);
224 goto done;
227 buffer = malloc(valueDataLen + sizeof(WCHAR));
228 lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)buffer, &valueDataLen);
229 if (lRet) {
230 error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName);
231 goto done;
233 if((valueDataLen % sizeof(WCHAR)) == 0)
234 buffer[valueDataLen / sizeof(WCHAR)] = 0;
235 if(len) *len = valueDataLen;
236 return buffer;
238 done:
239 free(buffer);
240 return NULL;
243 BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR keyName)
245 BOOL result = FALSE;
246 LONG lRet = ERROR_SUCCESS;
247 HKEY retKey = NULL;
248 WCHAR newKey[MAX_NEW_KEY_LEN - 4];
249 int keyNum;
250 HKEY hKey;
252 lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_CREATE_SUB_KEY, &hKey);
253 if (lRet) {
254 error_code_messagebox(hwnd, IDS_CREATE_KEY_FAILED);
255 goto done;
258 if (!LoadStringW(GetModuleHandleW(0), IDS_NEWKEY, newKey, ARRAY_SIZE(newKey))) goto done;
260 /* try to find a name for the key being created (maximum = 100 attempts) */
261 for (keyNum = 1; keyNum < 100; keyNum++) {
262 wsprintfW(keyName, newKey, keyNum);
263 lRet = RegOpenKeyW(hKey, keyName, &retKey);
264 if (lRet) break;
265 RegCloseKey(retKey);
267 if (lRet == ERROR_SUCCESS) goto done;
269 lRet = RegCreateKeyW(hKey, keyName, &retKey);
270 if (lRet) {
271 error_code_messagebox(hwnd, IDS_CREATE_KEY_FAILED);
272 goto done;
275 result = TRUE;
277 done:
278 RegCloseKey(retKey);
279 return result;
282 BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
284 BOOL result = FALSE;
285 DWORD type;
286 LONG lRet;
287 HKEY hKey;
288 LONG len;
290 lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ | KEY_SET_VALUE, &hKey);
291 if (lRet) {
292 error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED);
293 return FALSE;
296 editValueName = valueName ? valueName : g_pszDefaultValueName;
297 if(!(stringValueData = read_value(hwnd, hKey, valueName, &type, &len))) goto done;
299 if ( (type == REG_SZ) || (type == REG_EXPAND_SZ) ) {
300 if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) {
301 lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)stringValueData, (lstrlenW(stringValueData) + 1) * sizeof(WCHAR));
302 if (lRet == ERROR_SUCCESS) result = TRUE;
303 else error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED);
305 } else if ( type == REG_DWORD ) {
306 DWORD value = *((DWORD*)stringValueData);
307 stringValueData = realloc(stringValueData, 64);
308 wsprintfW(stringValueData, L"%x", value);
309 if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_DWORD), hwnd, modify_dlgproc) == IDOK)
311 DWORD val;
312 if (swscanf(stringValueData, isDecimal ? L"%lu" : L"%lx", &val))
314 lRet = RegSetValueExW(hKey, valueName, 0, type, (BYTE*)&val, sizeof(val));
315 if (lRet == ERROR_SUCCESS) result = TRUE;
316 else error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED);
319 } else if ( type == REG_QWORD ) {
320 UINT64 value = *((UINT64 *)stringValueData);
321 stringValueData = realloc(stringValueData, 64);
322 swprintf(stringValueData, 64, L"%I64x", value);
323 if (DialogBoxParamW(0, MAKEINTRESOURCEW(IDD_EDIT_DWORD), hwnd, modify_dlgproc, type) == IDOK)
325 if (swscanf(stringValueData, isDecimal ? L"%I64u" : L"%I64x", &value))
327 lRet = RegSetValueExW(hKey, valueName, 0, type, (BYTE *)&value, sizeof(value));
328 if (lRet == ERROR_SUCCESS) result = TRUE;
329 else error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED);
332 } else if ( type == REG_MULTI_SZ ) {
333 WCHAR char1 = '\r', char2 = '\n';
334 WCHAR *tmpValueData = NULL;
335 INT i, j, count;
337 for (i = 0, count = 0; i < len / sizeof(WCHAR); i++)
338 if ( !stringValueData[i] && stringValueData[i + 1] )
339 count++;
340 tmpValueData = malloc(len + (count * sizeof(WCHAR)));
342 for ( i = 0, j = 0; i < len / sizeof(WCHAR); i++)
344 if ( !stringValueData[i] && stringValueData[i + 1])
346 tmpValueData[j++] = char1;
347 tmpValueData[j++] = char2;
349 else
350 tmpValueData[j++] = stringValueData[i];
353 free(stringValueData);
354 stringValueData = tmpValueData;
355 tmpValueData = NULL;
357 if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_MULTI_STRING), hwnd, modify_dlgproc) == IDOK)
359 len = lstrlenW( stringValueData );
360 tmpValueData = malloc((len + 2) * sizeof(WCHAR));
362 for (i = 0, j = 0; i < len; i++)
364 if ( stringValueData[i] == char1 && stringValueData[i + 1] == char2)
366 if ( tmpValueData[j - 1] != 0)
367 tmpValueData[j++] = 0;
368 i++;
370 else
371 tmpValueData[j++] = stringValueData[i];
374 tmpValueData[j++] = 0;
375 tmpValueData[j++] = 0;
376 free(stringValueData);
377 stringValueData = tmpValueData;
379 lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)stringValueData, j * sizeof(WCHAR));
380 if (lRet == ERROR_SUCCESS) result = TRUE;
381 else error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED);
384 else /* hex data types */
386 struct edit_params params;
388 params.hkey = hKey;
389 params.value_name = valueName;
390 params.type = type;
391 params.data = stringValueData;
392 params.size = len;
393 result = DialogBoxParamW(NULL, MAKEINTRESOURCEW(IDD_EDIT_BINARY), hwnd,
394 bin_modify_dlgproc, (LPARAM)&params);
397 /* Update the listview item with the new data string */
398 if (result)
400 int index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1,
401 MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
402 free(stringValueData);
403 stringValueData = read_value(hwnd, hKey, valueName, &type, &len);
404 format_value_data(g_pChildWnd->hListWnd, index, type, stringValueData, len);
407 done:
408 free(stringValueData);
409 stringValueData = NULL;
410 RegCloseKey(hKey);
411 return result;
414 BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
416 BOOL result = FALSE;
417 LONG lRet;
418 HKEY hKey;
420 lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ|KEY_SET_VALUE, &hKey);
421 if (lRet) {
422 error_code_messagebox(hwnd, IDS_DELETE_KEY_FAILED);
423 return FALSE;
426 if (messagebox(hwnd, MB_YESNO | MB_ICONEXCLAMATION, IDS_DELETE_KEY_TITLE,
427 IDS_DELETE_KEY_TEXT) != IDYES)
428 goto done;
430 lRet = SHDeleteKeyW(hKeyRoot, keyPath);
431 if (lRet) {
432 error_code_messagebox(hwnd, IDS_BAD_KEY, keyPath);
433 goto done;
435 result = TRUE;
437 done:
438 RegCloseKey(hKey);
439 return result;
442 BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
444 BOOL result = FALSE;
445 LONG lRet;
446 HKEY hKey;
448 lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ | KEY_SET_VALUE, &hKey);
449 if (lRet) return FALSE;
451 lRet = RegDeleteValueW(hKey, valueName);
452 if (lRet && valueName) {
453 error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName);
455 if (lRet) goto done;
456 result = TRUE;
458 done:
459 RegCloseKey(hKey);
460 return result;
463 BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, DWORD valueType, LPWSTR valueName)
465 LONG lRet = ERROR_SUCCESS;
466 WCHAR newValue[256];
467 UINT64 value = 0;
468 DWORD size_bytes;
469 BOOL result = FALSE;
470 int valueNum, index;
471 HKEY hKey;
472 LVITEMW item;
474 lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ | KEY_SET_VALUE, &hKey);
475 if (lRet) {
476 error_code_messagebox(hwnd, IDS_CREATE_VALUE_FAILED);
477 return FALSE;
480 if (!LoadStringW(GetModuleHandleW(0), IDS_NEWVALUE, newValue, ARRAY_SIZE(newValue))) goto done;
482 /* try to find a name for the value being created (maximum = 100 attempts) */
483 for (valueNum = 1; valueNum < 100; valueNum++) {
484 wsprintfW(valueName, newValue, valueNum);
485 lRet = RegQueryValueExW(hKey, valueName, 0, 0, 0, 0);
486 if (lRet == ERROR_FILE_NOT_FOUND) break;
488 if (lRet != ERROR_FILE_NOT_FOUND) {
489 error_code_messagebox(hwnd, IDS_CREATE_VALUE_FAILED);
490 goto done;
493 switch (valueType)
495 case REG_DWORD:
496 case REG_DWORD_BIG_ENDIAN:
497 size_bytes = sizeof(DWORD);
498 break;
499 case REG_QWORD:
500 size_bytes = sizeof(UINT64);
501 break;
502 case REG_BINARY:
503 size_bytes = 0;
504 break;
505 case REG_MULTI_SZ:
506 size_bytes = 2 * sizeof(WCHAR);
507 break;
508 default: /* REG_NONE, REG_SZ, REG_EXPAND_SZ */
509 size_bytes = sizeof(WCHAR);
512 lRet = RegSetValueExW(hKey, valueName, 0, valueType, (BYTE *)&value, size_bytes);
513 if (lRet) {
514 error_code_messagebox(hwnd, IDS_CREATE_VALUE_FAILED);
515 goto done;
518 /* Add the new item to the listview */
519 index = AddEntryToList(g_pChildWnd->hListWnd, valueName, valueType, (BYTE *)&value, size_bytes, -1);
520 item.state = LVIS_FOCUSED | LVIS_SELECTED;
521 item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
522 SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMSTATE, index, (LPARAM)&item);
524 result = TRUE;
526 done:
527 RegCloseKey(hKey);
528 return result;
531 BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPCWSTR newName)
533 LPWSTR value = NULL;
534 DWORD type;
535 LONG len, lRet;
536 BOOL result = FALSE;
537 HKEY hKey;
539 if (!oldName) return FALSE;
540 if (!newName) return FALSE;
542 lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ | KEY_SET_VALUE, &hKey);
543 if (lRet) {
544 error_code_messagebox(hwnd, IDS_RENAME_VALUE_FAILED);
545 return FALSE;
548 if (!RegQueryValueExW(hKey, newName, NULL, NULL, NULL, NULL)) {
549 error_code_messagebox(hwnd, IDS_VALUE_EXISTS, oldName);
550 goto done;
552 value = read_value(hwnd, hKey, oldName, &type, &len);
553 if(!value) goto done;
554 lRet = RegSetValueExW(hKey, newName, 0, type, (BYTE*)value, len);
555 if (lRet) {
556 error_code_messagebox(hwnd, IDS_RENAME_VALUE_FAILED);
557 goto done;
559 lRet = RegDeleteValueW(hKey, oldName);
560 if (lRet) {
561 RegDeleteValueW(hKey, newName);
562 error_code_messagebox(hwnd, IDS_RENAME_VALUE_FAILED);
563 goto done;
565 result = TRUE;
567 done:
568 free(value);
569 RegCloseKey(hKey);
570 return result;
574 BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
576 LPWSTR parentPath = 0;
577 LPCWSTR srcSubKey = 0;
578 HKEY parentKey = 0;
579 HKEY destKey = 0;
580 BOOL result = FALSE;
581 LONG lRet;
582 DWORD disposition;
584 if (!keyPath || !newName) return FALSE;
586 if (!wcsrchr(keyPath, '\\')) {
587 parentKey = hRootKey;
588 srcSubKey = keyPath;
589 } else {
590 LPWSTR srcSubKey_copy;
592 parentPath = malloc((lstrlenW(keyPath) + 1) * sizeof(WCHAR));
593 lstrcpyW(parentPath, keyPath);
594 srcSubKey_copy = wcsrchr(parentPath, '\\');
595 *srcSubKey_copy = 0;
596 srcSubKey = srcSubKey_copy + 1;
597 lRet = RegOpenKeyExW(hRootKey, parentPath, 0, KEY_READ | KEY_CREATE_SUB_KEY, &parentKey);
598 if (lRet) {
599 error_code_messagebox(hwnd, IDS_RENAME_KEY_FAILED);
600 goto done;
604 /* The following fails if the old name is the same as the new name. */
605 if (!lstrcmpW(srcSubKey, newName)) goto done;
607 lRet = RegCreateKeyExW(parentKey, newName, 0, NULL, REG_OPTION_NON_VOLATILE,
608 KEY_WRITE, NULL /* FIXME */, &destKey, &disposition);
609 if (disposition == REG_OPENED_EXISTING_KEY)
610 lRet = ERROR_FILE_EXISTS;
611 if (lRet) {
612 error_code_messagebox(hwnd, IDS_KEY_EXISTS, srcSubKey);
613 goto done;
616 /* FIXME: SHCopyKey does not copy the security attributes */
617 lRet = SHCopyKeyW(parentKey, srcSubKey, destKey, 0);
618 if (lRet) {
619 RegCloseKey(destKey);
620 RegDeleteKeyW(parentKey, newName);
621 error_code_messagebox(hwnd, IDS_RENAME_KEY_FAILED);
622 goto done;
625 lRet = SHDeleteKeyW(hRootKey, keyPath);
626 if (lRet) {
627 error_code_messagebox(hwnd, IDS_RENAME_KEY_FAILED);
628 goto done;
631 result = TRUE;
633 done:
634 RegCloseKey(destKey);
635 if (parentKey) {
636 RegCloseKey(parentKey);
637 free(parentPath);
639 return result;