Commit 455ce06d authored by Alexander Nicolaysen Sørnes's avatar Alexander Nicolaysen Sørnes Committed by Alexandre Julliard

regedit: Convert favourites handling to unicode.

parent 039df36b
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
* Global and Local Variables: * Global and Local Variables:
*/ */
static TCHAR favoritesKey[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\RegEdit\\Favorites"); static WCHAR favoritesKey[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','A','p','p','l','e','t','s','\\','R','e','g','E','d','i','t','\\','F','a','v','o','r','i','t','e','s',0};
static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */ static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
static TCHAR favoriteName[128]; static WCHAR favoriteName[128];
static TCHAR searchString[128]; static TCHAR searchString[128];
static int searchMask = SEARCH_KEYS | SEARCH_VALUES | SEARCH_CONTENT; static int searchMask = SEARCH_KEYS | SEARCH_VALUES | SEARCH_CONTENT;
...@@ -123,9 +123,9 @@ static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem) ...@@ -123,9 +123,9 @@ static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem)
HKEY hKey; HKEY hKey;
while(GetMenuItemCount(hMenu)>2) while(GetMenuItemCount(hMenu)>2)
DeleteMenu(hMenu, 2, MF_BYPOSITION); DeleteMenu(hMenu, 2, MF_BYPOSITION);
if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey, if (RegOpenKeyExW(HKEY_CURRENT_USER, favoritesKey,
0, KEY_READ, &hKey) == ERROR_SUCCESS) { 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
TCHAR namebuf[KEY_MAX_LEN]; WCHAR namebuf[KEY_MAX_LEN];
BYTE valuebuf[4096]; BYTE valuebuf[4096];
int i = 0; int i = 0;
BOOL sep = FALSE; BOOL sep = FALSE;
...@@ -134,15 +134,15 @@ static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem) ...@@ -134,15 +134,15 @@ static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem)
do { do {
ksize = KEY_MAX_LEN; ksize = KEY_MAX_LEN;
vsize = sizeof(valuebuf); vsize = sizeof(valuebuf);
error = RegEnumValue(hKey, i, namebuf, &ksize, NULL, &type, valuebuf, &vsize); error = RegEnumValueW(hKey, i, namebuf, &ksize, NULL, &type, valuebuf, &vsize);
if (error != ERROR_SUCCESS) if (error != ERROR_SUCCESS)
break; break;
if (type == REG_SZ) { if (type == REG_SZ) {
if (!sep) { if (!sep) {
AppendMenu(hMenu, MF_SEPARATOR, -1, NULL); AppendMenuW(hMenu, MF_SEPARATOR, -1, NULL);
sep = TRUE; sep = TRUE;
} }
AppendMenu(hMenu, MF_STRING, ID_FAVORITE_FIRST+i, namebuf); AppendMenuW(hMenu, MF_STRING, ID_FAVORITE_FIRST+i, namebuf);
} }
i++; i++;
} while(error == ERROR_SUCCESS); } while(error == ERROR_SUCCESS);
...@@ -524,13 +524,13 @@ static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w ...@@ -524,13 +524,13 @@ static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
HKEY hKeyRoot = NULL; HKEY hKeyRoot = NULL;
LPSTR ItemPath = GetItemPath(g_pChildWnd->hTreeWnd, NULL, &hKeyRoot); LPWSTR ItemPath = GetItemPathW(g_pChildWnd->hTreeWnd, NULL, &hKeyRoot);
if(!ItemPath || !*ItemPath) if(!ItemPath || !*ItemPath)
ItemPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE); ItemPath = GetItemFullPathW(g_pChildWnd->hTreeWnd, NULL, FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
SetWindowText(hwndValue, ItemPath); SetWindowTextW(hwndValue, ItemPath);
SendMessage(hwndValue, EM_SETLIMITTEXT, 127, 0); SendMessageW(hwndValue, EM_SETLIMITTEXT, 127, 0);
return TRUE; return TRUE;
} }
case WM_COMMAND: case WM_COMMAND:
...@@ -542,8 +542,8 @@ static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w ...@@ -542,8 +542,8 @@ static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
} }
break; break;
case IDOK: case IDOK:
if (GetWindowTextLength(hwndValue)>0) { if (GetWindowTextLengthW(hwndValue)>0) {
GetWindowText(hwndValue, favoriteName, 128); GetWindowTextW(hwndValue, favoriteName, 128);
EndDialog(hwndDlg, IDOK); EndDialog(hwndDlg, IDOK);
} }
return TRUE; return TRUE;
...@@ -565,20 +565,20 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w ...@@ -565,20 +565,20 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
HKEY hKey; HKEY hKey;
int i = 0; int i = 0;
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey, if (RegOpenKeyExW(HKEY_CURRENT_USER, favoritesKey,
0, KEY_READ, &hKey) == ERROR_SUCCESS) { 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
TCHAR namebuf[KEY_MAX_LEN]; WCHAR namebuf[KEY_MAX_LEN];
BYTE valuebuf[4096]; BYTE valuebuf[4096];
DWORD ksize, vsize, type; DWORD ksize, vsize, type;
LONG error; LONG error;
do { do {
ksize = KEY_MAX_LEN; ksize = KEY_MAX_LEN;
vsize = sizeof(valuebuf); vsize = sizeof(valuebuf);
error = RegEnumValue(hKey, i, namebuf, &ksize, NULL, &type, valuebuf, &vsize); error = RegEnumValueW(hKey, i, namebuf, &ksize, NULL, &type, valuebuf, &vsize);
if (error != ERROR_SUCCESS) if (error != ERROR_SUCCESS)
break; break;
if (type == REG_SZ) { if (type == REG_SZ) {
SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)namebuf); SendMessageW(hwndList, LB_ADDSTRING, 0, (LPARAM)namebuf);
} }
i++; i++;
} while(error == ERROR_SUCCESS); } while(error == ERROR_SUCCESS);
...@@ -587,7 +587,7 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w ...@@ -587,7 +587,7 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
else else
return FALSE; return FALSE;
EnableWindow(GetDlgItem(hwndDlg, IDOK), i != 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), i != 0);
SendMessage(hwndList, LB_SETCURSEL, 0, 0); SendMessageW(hwndList, LB_SETCURSEL, 0, 0);
return TRUE; return TRUE;
} }
case WM_COMMAND: case WM_COMMAND:
...@@ -602,11 +602,11 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w ...@@ -602,11 +602,11 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
int pos = SendMessage(hwndList, LB_GETCURSEL, 0, 0); int pos = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
int len = SendMessage(hwndList, LB_GETTEXTLEN, pos, 0); int len = SendMessage(hwndList, LB_GETTEXTLEN, pos, 0);
if (len>0) { if (len>0) {
LPTSTR lpName = HeapAlloc(GetProcessHeap(), 0, sizeof(TCHAR)*(len+1)); LPWSTR lpName = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(len+1));
SendMessage(hwndList, LB_GETTEXT, pos, (LPARAM)lpName); SendMessageW(hwndList, LB_GETTEXT, pos, (LPARAM)lpName);
if (len>127) if (len>127)
lpName[127] = '\0'; lpName[127] = '\0';
_tcscpy(favoriteName, lpName); lstrcpyW(favoriteName, lpName);
EndDialog(hwndDlg, IDOK); EndDialog(hwndDlg, IDOK);
HeapFree(GetProcessHeap(), 0, lpName); HeapFree(GetProcessHeap(), 0, lpName);
} }
...@@ -642,15 +642,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -642,15 +642,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (LOWORD(wParam) >= ID_FAVORITE_FIRST && LOWORD(wParam) <= ID_FAVORITE_LAST) { if (LOWORD(wParam) >= ID_FAVORITE_FIRST && LOWORD(wParam) <= ID_FAVORITE_LAST) {
HKEY hKey; HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey, if (RegOpenKeyExW(HKEY_CURRENT_USER, favoritesKey,
0, KEY_READ, &hKey) == ERROR_SUCCESS) { 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
TCHAR namebuf[KEY_MAX_LEN]; WCHAR namebuf[KEY_MAX_LEN];
BYTE valuebuf[4096]; BYTE valuebuf[4096];
DWORD ksize = KEY_MAX_LEN, vsize = sizeof(valuebuf), type = 0; DWORD ksize = KEY_MAX_LEN, vsize = sizeof(valuebuf), type = 0;
if (RegEnumValue(hKey, LOWORD(wParam) - ID_FAVORITE_FIRST, namebuf, &ksize, NULL, if (RegEnumValueW(hKey, LOWORD(wParam) - ID_FAVORITE_FIRST, namebuf, &ksize, NULL,
&type, valuebuf, &vsize) == ERROR_SUCCESS) { &type, valuebuf, &vsize) == ERROR_SUCCESS) {
SendMessage( g_pChildWnd->hTreeWnd, TVM_SELECTITEM, TVGN_CARET, SendMessageW( g_pChildWnd->hTreeWnd, TVM_SELECTITEM, TVGN_CARET,
(LPARAM) FindPathInTree(g_pChildWnd->hTreeWnd, (TCHAR *)valuebuf) ); (LPARAM) FindPathInTree(g_pChildWnd->hTreeWnd, (WCHAR *)valuebuf) );
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
...@@ -813,13 +813,13 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -813,13 +813,13 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ID_FAVORITES_ADDTOFAVORITES: case ID_FAVORITES_ADDTOFAVORITES:
{ {
HKEY hKey; HKEY hKey;
LPTSTR lpKeyPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE); LPWSTR lpKeyPath = GetItemFullPathW(g_pChildWnd->hTreeWnd, NULL, FALSE);
if (lpKeyPath) { if (lpKeyPath) {
if (DialogBox(0, MAKEINTRESOURCE(IDD_ADDFAVORITE), hWnd, addtofavorites_dlgproc) == IDOK) { if (DialogBox(0, MAKEINTRESOURCE(IDD_ADDFAVORITE), hWnd, addtofavorites_dlgproc) == IDOK) {
if (RegCreateKeyEx(HKEY_CURRENT_USER, favoritesKey, if (RegCreateKeyExW(HKEY_CURRENT_USER, favoritesKey,
0, NULL, 0, 0, NULL, 0,
KEY_READ|KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) { KEY_READ|KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
RegSetValueEx(hKey, favoriteName, 0, REG_SZ, (BYTE *)lpKeyPath, (_tcslen(lpKeyPath)+1)*sizeof(TCHAR)); RegSetValueExW(hKey, favoriteName, 0, REG_SZ, (BYTE *)lpKeyPath, (lstrlenW(lpKeyPath)+1)*sizeof(WCHAR));
RegCloseKey(hKey); RegCloseKey(hKey);
} }
} }
...@@ -831,9 +831,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -831,9 +831,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
if (DialogBox(0, MAKEINTRESOURCE(IDD_DELFAVORITE), hWnd, removefavorite_dlgproc) == IDOK) { if (DialogBox(0, MAKEINTRESOURCE(IDD_DELFAVORITE), hWnd, removefavorite_dlgproc) == IDOK) {
HKEY hKey; HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey, if (RegOpenKeyExW(HKEY_CURRENT_USER, favoritesKey,
0, KEY_READ|KEY_WRITE, &hKey) == ERROR_SUCCESS) { 0, KEY_READ|KEY_WRITE, &hKey) == ERROR_SUCCESS) {
RegDeleteValue(hKey, favoriteName); RegDeleteValueW(hKey, favoriteName);
RegCloseKey(hKey); RegCloseKey(hKey);
} }
} }
......
...@@ -136,7 +136,7 @@ extern LPWSTR GetItemPathW(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey); ...@@ -136,7 +136,7 @@ extern LPWSTR GetItemPathW(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
extern BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem); extern BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem);
extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name); extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name);
extern HWND StartKeyRename(HWND hwndTV); extern HWND StartKeyRename(HWND hwndTV);
extern HTREEITEM FindPathInTree(HWND hwndTV, LPCTSTR lpKeyName); extern HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName);
extern HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode, int *row); extern HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode, int *row);
/* edit.c */ /* edit.c */
......
...@@ -166,9 +166,9 @@ LPWSTR GetItemPathW(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey) ...@@ -166,9 +166,9 @@ LPWSTR GetItemPathW(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
return pathBuffer; return pathBuffer;
} }
static LPTSTR get_path_component(LPCTSTR *lplpKeyName) { static LPWSTR get_path_component(LPCWSTR *lplpKeyName) {
LPCTSTR lpPos = *lplpKeyName; LPCWSTR lpPos = *lplpKeyName;
LPTSTR lpResult = NULL; LPWSTR lpResult = NULL;
int len; int len;
if (!lpPos) if (!lpPos)
return NULL; return NULL;
...@@ -176,37 +176,37 @@ static LPTSTR get_path_component(LPCTSTR *lplpKeyName) { ...@@ -176,37 +176,37 @@ static LPTSTR get_path_component(LPCTSTR *lplpKeyName) {
lpPos++; lpPos++;
if (*lpPos && lpPos == *lplpKeyName) if (*lpPos && lpPos == *lplpKeyName)
return NULL; return NULL;
len = (lpPos+1-(*lplpKeyName)) * sizeof(TCHAR); len = lpPos+1-(*lplpKeyName);
lpResult = HeapAlloc(GetProcessHeap(), 0, len); lpResult = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!lpResult) /* that would be very odd */ if (!lpResult) /* that would be very odd */
return NULL; return NULL;
memcpy(lpResult, *lplpKeyName, len-1); lstrcpynW(lpResult, *lplpKeyName, len);
lpResult[len-1] = '\0';
*lplpKeyName = *lpPos ? lpPos+1 : NULL; *lplpKeyName = *lpPos ? lpPos+1 : NULL;
return lpResult; return lpResult;
} }
HTREEITEM FindPathInTree(HWND hwndTV, LPCTSTR lpKeyName) { HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
TVITEMEX tvi; TVITEMEXW tvi;
TCHAR buf[261]; /* tree view has 260 character limitation on item name */ WCHAR buf[261]; /* tree view has 260 character limitation on item name */
HTREEITEM hItem, hOldItem; HTREEITEM hItem, hOldItem;
buf[260] = '\0'; buf[260] = '\0';
hItem = TreeView_GetRoot(hwndTV); hItem = TreeView_GetRoot(hwndTV);
SendMessage(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem ); SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
hItem = TreeView_GetChild(hwndTV, hItem); hItem = TreeView_GetChild(hwndTV, hItem);
hOldItem = hItem; hOldItem = hItem;
while(1) { while(1) {
LPTSTR lpItemName = get_path_component(&lpKeyName); LPWSTR lpItemName = get_path_component(&lpKeyName);
if (lpItemName) { if (lpItemName) {
while(hItem) { while(hItem) {
tvi.mask = TVIF_TEXT | TVIF_HANDLE; tvi.mask = TVIF_TEXT | TVIF_HANDLE;
tvi.hItem = hItem; tvi.hItem = hItem;
tvi.pszText = buf; tvi.pszText = buf;
tvi.cchTextMax = 260; tvi.cchTextMax = 260;
SendMessage(hwndTV, TVM_GETITEM, 0, (LPARAM) &tvi); SendMessageW(hwndTV, TVM_GETITEMW, 0, (LPARAM) &tvi);
if (!_tcsicmp(tvi.pszText, lpItemName)) { if (!lstrcmpiW(tvi.pszText, lpItemName)) {
SendMessage(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem ); SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
if (!lpKeyName) if (!lpKeyName)
return hItem; return hItem;
hOldItem = hItem; hOldItem = hItem;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment