regedit: Convert key renaming to unicode.
This commit is contained in:
parent
4a3d8d8cb0
commit
6b7ebf0881
|
@ -25,6 +25,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "regproc.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/unicode.h"
|
||||
|
@ -219,13 +220,13 @@ LPWSTR GetItemFullPathW(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static LPTSTR GetPathFullPath(HWND hwndTV, LPTSTR path) {
|
||||
LPTSTR parts[2];
|
||||
LPTSTR ret;
|
||||
static LPWSTR GetPathFullPath(HWND hwndTV, LPWSTR path) {
|
||||
LPWSTR parts[2];
|
||||
LPWSTR ret;
|
||||
|
||||
parts[0] = GetPathRoot(hwndTV, 0, TRUE);
|
||||
parts[0] = GetPathRootW(hwndTV, 0, TRUE);
|
||||
parts[1] = path;
|
||||
ret = CombinePaths((LPCTSTR *)parts, 2);
|
||||
ret = CombinePathsW((LPCWSTR*)parts, 2);
|
||||
HeapFree(GetProcessHeap(), 0, parts[0]);
|
||||
return ret;
|
||||
}
|
||||
|
@ -424,19 +425,22 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
case TVN_ENDLABELEDIT: {
|
||||
HKEY hRootKey;
|
||||
LPNMTVDISPINFO dispInfo = (LPNMTVDISPINFO)lParam;
|
||||
LPCTSTR path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
|
||||
BOOL res = RenameKey(hWnd, hRootKey, path, dispInfo->item.pszText);
|
||||
WCHAR* itemText = GetWideString(dispInfo->item.pszText);
|
||||
LPWSTR path = GetItemPathW(g_pChildWnd->hTreeWnd, 0, &hRootKey);
|
||||
BOOL res = RenameKey(hWnd, hRootKey, path, itemText);
|
||||
if (res) {
|
||||
TVITEMEX item;
|
||||
LPTSTR fullPath = GetPathFullPath(g_pChildWnd->hTreeWnd,
|
||||
dispInfo->item.pszText);
|
||||
TVITEMEXW item;
|
||||
LPWSTR fullPath = GetPathFullPath(g_pChildWnd->hTreeWnd,
|
||||
itemText);
|
||||
item.mask = TVIF_HANDLE | TVIF_TEXT;
|
||||
item.hItem = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
|
||||
item.pszText = dispInfo->item.pszText;
|
||||
SendMessage( g_pChildWnd->hTreeWnd, TVM_SETITEMW, 0, (LPARAM)&item );
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
|
||||
item.pszText = itemText;
|
||||
SendMessageW( g_pChildWnd->hTreeWnd, TVM_SETITEMW, 0, (LPARAM)&item );
|
||||
SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
|
||||
HeapFree(GetProcessHeap(), 0, fullPath);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, path);
|
||||
HeapFree(GetProcessHeap(), 0, itemText);
|
||||
return res;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <shellapi.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include "wine/unicode.h"
|
||||
#include "main.h"
|
||||
#include "regproc.h"
|
||||
#include "resource.h"
|
||||
|
@ -536,10 +537,10 @@ done:
|
|||
}
|
||||
|
||||
|
||||
BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR newName)
|
||||
BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
|
||||
{
|
||||
LPTSTR parentPath = 0;
|
||||
LPCTSTR srcSubKey = 0;
|
||||
LPWSTR parentPath = 0;
|
||||
LPCWSTR srcSubKey = 0;
|
||||
HKEY parentKey = 0;
|
||||
HKEY destKey = 0;
|
||||
BOOL result = FALSE;
|
||||
|
@ -548,17 +549,18 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR newName)
|
|||
|
||||
if (!keyPath || !newName) return FALSE;
|
||||
|
||||
if (!strrchr(keyPath, '\\')) {
|
||||
if (!strrchrW(keyPath, '\\')) {
|
||||
parentKey = hRootKey;
|
||||
srcSubKey = keyPath;
|
||||
} else {
|
||||
LPTSTR srcSubKey_copy;
|
||||
LPWSTR srcSubKey_copy;
|
||||
|
||||
parentPath = strdup(keyPath);
|
||||
srcSubKey_copy = strrchr(parentPath, '\\');
|
||||
parentPath = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(keyPath)+1)*sizeof(WCHAR));
|
||||
lstrcpyW(parentPath, keyPath);
|
||||
srcSubKey_copy = strrchrW(parentPath, '\\');
|
||||
*srcSubKey_copy = 0;
|
||||
srcSubKey = srcSubKey_copy + 1;
|
||||
lRet = RegOpenKeyEx(hRootKey, parentPath, 0, KEY_READ | KEY_CREATE_SUB_KEY, &parentKey);
|
||||
lRet = RegOpenKeyExW(hRootKey, parentPath, 0, KEY_READ | KEY_CREATE_SUB_KEY, &parentKey);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
error_code_messagebox(hwnd, lRet);
|
||||
goto done;
|
||||
|
@ -566,9 +568,9 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR newName)
|
|||
}
|
||||
|
||||
/* The following fails if the old name is the same as the new name. */
|
||||
if (!strcmp(srcSubKey, newName)) goto done;
|
||||
if (!lstrcmpW(srcSubKey, newName)) goto done;
|
||||
|
||||
lRet = RegCreateKeyEx(parentKey, newName, 0, NULL, REG_OPTION_NON_VOLATILE,
|
||||
lRet = RegCreateKeyExW(parentKey, newName, 0, NULL, REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE, NULL /* FIXME */, &destKey, &disposition);
|
||||
if (disposition == REG_OPENED_EXISTING_KEY)
|
||||
lRet = ERROR_FILE_EXISTS; /* FIXME: we might want a better error message than this */
|
||||
|
@ -578,15 +580,15 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR newName)
|
|||
}
|
||||
|
||||
/* FIXME: SHCopyKey does not copy the security attributes */
|
||||
lRet = SHCopyKey(parentKey, srcSubKey, destKey, 0);
|
||||
lRet = SHCopyKeyW(parentKey, srcSubKey, destKey, 0);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
RegCloseKey(destKey);
|
||||
RegDeleteKey(parentKey, newName);
|
||||
RegDeleteKeyW(parentKey, newName);
|
||||
error_code_messagebox(hwnd, lRet);
|
||||
goto done;
|
||||
}
|
||||
|
||||
lRet = SHDeleteKey(hRootKey, keyPath);
|
||||
lRet = SHDeleteKeyW(hRootKey, keyPath);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
error_code_messagebox(hwnd, lRet);
|
||||
goto done;
|
||||
|
@ -598,7 +600,7 @@ done:
|
|||
RegCloseKey(destKey);
|
||||
if (parentKey) {
|
||||
RegCloseKey(parentKey);
|
||||
free(parentPath);
|
||||
HeapFree(GetProcessHeap(), 0, parentPath);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ extern BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR value
|
|||
extern BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath);
|
||||
extern BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName, BOOL showMessageBox);
|
||||
extern BOOL RenameValue(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR oldName, LPCWSTR newName);
|
||||
extern BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR newName);
|
||||
extern BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName);
|
||||
extern void error(HWND hwnd, INT resId, ...);
|
||||
|
||||
/* hexedit.c */
|
||||
|
|
Loading…
Reference in New Issue