regedit: Convert key creation to unicode.
This commit is contained in:
parent
f208025228
commit
a6a4109dd4
|
@ -242,33 +242,33 @@ done:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPTSTR keyName)
|
||||
BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR keyName)
|
||||
{
|
||||
BOOL result = FALSE;
|
||||
LONG lRet = ERROR_SUCCESS;
|
||||
HKEY retKey = NULL;
|
||||
TCHAR newKey[MAX_NEW_KEY_LEN - 4];
|
||||
WCHAR newKey[MAX_NEW_KEY_LEN - 4];
|
||||
int keyNum;
|
||||
HKEY hKey;
|
||||
|
||||
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_CREATE_SUB_KEY, &hKey);
|
||||
lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_CREATE_SUB_KEY, &hKey);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
error_code_messagebox(hwnd, lRet);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!LoadString(GetModuleHandle(0), IDS_NEWKEY, newKey, COUNT_OF(newKey))) goto done;
|
||||
if (!LoadStringW(GetModuleHandle(0), IDS_NEWKEY, newKey, COUNT_OF(newKey))) goto done;
|
||||
|
||||
/* try to find out a name for the newly create key (max 100 times) */
|
||||
for (keyNum = 1; keyNum < 100; keyNum++) {
|
||||
wsprintf(keyName, newKey, keyNum);
|
||||
lRet = RegOpenKey(hKey, keyName, &retKey);
|
||||
wsprintfW(keyName, newKey, keyNum);
|
||||
lRet = RegOpenKeyW(hKey, keyName, &retKey);
|
||||
if (lRet != ERROR_SUCCESS) break;
|
||||
RegCloseKey(retKey);
|
||||
}
|
||||
if (lRet == ERROR_SUCCESS) goto done;
|
||||
|
||||
lRet = RegCreateKey(hKey, keyName, &retKey);
|
||||
lRet = RegCreateKeyW(hKey, keyName, &retKey);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
error_code_messagebox(hwnd, lRet);
|
||||
goto done;
|
||||
|
|
|
@ -761,10 +761,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
}
|
||||
case ID_EDIT_NEW_KEY:
|
||||
if (CreateKey(hWnd, hKeyRoot, keyPath, newKey)) {
|
||||
if (InsertNode(g_pChildWnd->hTreeWnd, 0, newKey))
|
||||
StartKeyRename(g_pChildWnd->hTreeWnd);
|
||||
}
|
||||
{
|
||||
WCHAR newKeyW[MAX_NEW_KEY_LEN];
|
||||
WCHAR* keyPathW = GetWideString(keyPath);
|
||||
if (CreateKey(hWnd, hKeyRoot, keyPathW, newKeyW)) {
|
||||
if (InsertNode(g_pChildWnd->hTreeWnd, 0, newKeyW))
|
||||
StartKeyRename(g_pChildWnd->hTreeWnd);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, keyPathW);
|
||||
}
|
||||
break;
|
||||
case ID_EDIT_NEW_STRINGVALUE:
|
||||
valueType = REG_SZ;
|
||||
|
|
|
@ -134,13 +134,13 @@ extern BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);
|
|||
extern LPTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
|
||||
extern LPWSTR GetItemPathW(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
|
||||
extern BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem);
|
||||
extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name);
|
||||
extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name);
|
||||
extern HWND StartKeyRename(HWND hwndTV);
|
||||
extern HTREEITEM FindPathInTree(HWND hwndTV, LPCTSTR lpKeyName);
|
||||
extern HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode, int *row);
|
||||
|
||||
/* edit.c */
|
||||
extern BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPTSTR newKeyName);
|
||||
extern BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR newKeyName);
|
||||
extern BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, DWORD valueType, LPTSTR valueName);
|
||||
extern BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName);
|
||||
extern BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath);
|
||||
|
|
|
@ -518,7 +518,7 @@ BOOL RefreshTreeView(HWND hwndTV)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name)
|
||||
HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name)
|
||||
{
|
||||
TCHAR buf[MAX_NEW_KEY_LEN];
|
||||
HTREEITEM hNewItem = 0;
|
||||
|
@ -527,7 +527,9 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name)
|
|||
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
|
||||
if (!hItem) return FALSE;
|
||||
if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDEDONCE)) {
|
||||
hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
|
||||
char* nameA = GetMultiByteString(name);
|
||||
hNewItem = AddEntryToTree(hwndTV, hItem, nameA, 0, 0);
|
||||
HeapFree(GetProcessHeap(), 0, nameA);
|
||||
} else {
|
||||
item.mask = TVIF_CHILDREN | TVIF_HANDLE;
|
||||
item.hItem = hItem;
|
||||
|
@ -535,19 +537,21 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name)
|
|||
item.cChildren = 1;
|
||||
if (!TreeView_SetItem(hwndTV, &item)) return FALSE;
|
||||
}
|
||||
SendMessage(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
|
||||
SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
|
||||
if (!hNewItem) {
|
||||
char* nameA = GetMultiByteString(name);
|
||||
for(hNewItem = TreeView_GetChild(hwndTV, hItem); hNewItem; hNewItem = TreeView_GetNextSibling(hwndTV, hNewItem)) {
|
||||
item.mask = TVIF_HANDLE | TVIF_TEXT;
|
||||
item.hItem = hNewItem;
|
||||
item.pszText = buf;
|
||||
item.cchTextMax = COUNT_OF(buf);
|
||||
if (!TreeView_GetItem(hwndTV, &item)) continue;
|
||||
if (lstrcmp(name, item.pszText) == 0) break;
|
||||
if (lstrcmp(nameA, item.pszText) == 0) break;
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, nameA);
|
||||
}
|
||||
if (hNewItem)
|
||||
SendMessage(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hNewItem);
|
||||
SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hNewItem);
|
||||
|
||||
return hNewItem;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue