regedit: Convert searching to Unicode.
This commit is contained in:
parent
5c1fa0eede
commit
583bf6e4bf
|
@ -39,7 +39,7 @@
|
||||||
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 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 WCHAR favoriteName[128];
|
static WCHAR favoriteName[128];
|
||||||
static TCHAR searchString[128];
|
static WCHAR searchString[128];
|
||||||
static int searchMask = SEARCH_KEYS | SEARCH_VALUES | SEARCH_CONTENT;
|
static int searchMask = SEARCH_KEYS | SEARCH_VALUES | SEARCH_CONTENT;
|
||||||
|
|
||||||
static TCHAR FileNameBuffer[_MAX_PATH];
|
static TCHAR FileNameBuffer[_MAX_PATH];
|
||||||
|
@ -484,26 +484,26 @@ static INT_PTR CALLBACK find_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
|
||||||
CheckDlgButton(hwndDlg, IDC_FIND_VALUES, searchMask&SEARCH_VALUES ? BST_CHECKED : BST_UNCHECKED);
|
CheckDlgButton(hwndDlg, IDC_FIND_VALUES, searchMask&SEARCH_VALUES ? BST_CHECKED : BST_UNCHECKED);
|
||||||
CheckDlgButton(hwndDlg, IDC_FIND_CONTENT, searchMask&SEARCH_CONTENT ? BST_CHECKED : BST_UNCHECKED);
|
CheckDlgButton(hwndDlg, IDC_FIND_CONTENT, searchMask&SEARCH_CONTENT ? BST_CHECKED : BST_UNCHECKED);
|
||||||
CheckDlgButton(hwndDlg, IDC_FIND_WHOLE, searchMask&SEARCH_WHOLE ? BST_CHECKED : BST_UNCHECKED);
|
CheckDlgButton(hwndDlg, IDC_FIND_WHOLE, searchMask&SEARCH_WHOLE ? BST_CHECKED : BST_UNCHECKED);
|
||||||
SendMessage(hwndValue, EM_SETLIMITTEXT, 127, 0);
|
SendMessageW(hwndValue, EM_SETLIMITTEXT, 127, 0);
|
||||||
SetWindowText(hwndValue, searchString);
|
SetWindowTextW(hwndValue, searchString);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch(LOWORD(wParam)) {
|
switch(LOWORD(wParam)) {
|
||||||
case IDC_VALUE_NAME:
|
case IDC_VALUE_NAME:
|
||||||
if (HIWORD(wParam) == EN_UPDATE) {
|
if (HIWORD(wParam) == EN_UPDATE) {
|
||||||
EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(hwndValue)>0);
|
EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLengthW(hwndValue)>0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDOK:
|
case IDOK:
|
||||||
if (GetWindowTextLength(hwndValue)>0) {
|
if (GetWindowTextLengthW(hwndValue)>0) {
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_KEYS)) mask |= SEARCH_KEYS;
|
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_KEYS)) mask |= SEARCH_KEYS;
|
||||||
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_VALUES)) mask |= SEARCH_VALUES;
|
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_VALUES)) mask |= SEARCH_VALUES;
|
||||||
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_CONTENT)) mask |= SEARCH_CONTENT;
|
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_CONTENT)) mask |= SEARCH_CONTENT;
|
||||||
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_WHOLE)) mask |= SEARCH_WHOLE;
|
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_WHOLE)) mask |= SEARCH_WHOLE;
|
||||||
searchMask = mask;
|
searchMask = mask;
|
||||||
GetWindowText(hwndValue, searchString, 128);
|
GetWindowTextW(hwndValue, searchString, 128);
|
||||||
EndDialog(hwndDlg, IDOK);
|
EndDialog(hwndDlg, IDOK);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -747,7 +747,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
SetFocus(g_pChildWnd->hTreeWnd);
|
SetFocus(g_pChildWnd->hTreeWnd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error(hWnd, IDS_NOTFOUND, searchString);
|
CHAR* searchStringA = GetMultiByteString(searchString);
|
||||||
|
error(hWnd, IDS_NOTFOUND, searchStringA);
|
||||||
|
HeapFree(GetProcessHeap(), 0, searchStringA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -137,7 +137,7 @@ 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, LPCWSTR 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, LPCWSTR sstring, int mode, int *row);
|
||||||
|
|
||||||
/* edit.c */
|
/* edit.c */
|
||||||
extern BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR newKeyName);
|
extern BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR newKeyName);
|
||||||
|
|
|
@ -258,18 +258,18 @@ static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPWSTR label, HK
|
||||||
return TreeView_InsertItemW(hwndTV, &tvins);
|
return TreeView_InsertItemW(hwndTV, &tvins);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL match_string(LPCTSTR sstring1, LPCTSTR sstring2, int mode)
|
static BOOL match_string(LPCWSTR sstring1, LPCWSTR sstring2, int mode)
|
||||||
{
|
{
|
||||||
if (mode & SEARCH_WHOLE)
|
if (mode & SEARCH_WHOLE)
|
||||||
return !stricmp(sstring1, sstring2);
|
return !lstrcmpiW(sstring1, sstring2);
|
||||||
else
|
else
|
||||||
return NULL != StrStrI(sstring1, sstring2);
|
return NULL != StrStrIW(sstring1, sstring2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode, int *row)
|
static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, int *row)
|
||||||
{
|
{
|
||||||
TVITEM item;
|
TVITEMW item;
|
||||||
TCHAR keyname[KEY_MAX_LEN];
|
WCHAR keyname[KEY_MAX_LEN];
|
||||||
item.mask = TVIF_TEXT;
|
item.mask = TVIF_TEXT;
|
||||||
item.hItem = hItem;
|
item.hItem = hItem;
|
||||||
item.pszText = keyname;
|
item.pszText = keyname;
|
||||||
|
@ -282,16 +282,16 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode,
|
||||||
|
|
||||||
if (mode & (SEARCH_VALUES | SEARCH_CONTENT)) {
|
if (mode & (SEARCH_VALUES | SEARCH_CONTENT)) {
|
||||||
int i, adjust;
|
int i, adjust;
|
||||||
TCHAR valName[KEY_MAX_LEN], *KeyPath;
|
WCHAR valName[KEY_MAX_LEN], *KeyPath;
|
||||||
HKEY hKey, hRoot;
|
HKEY hKey, hRoot;
|
||||||
DWORD lenName;
|
DWORD lenName;
|
||||||
|
|
||||||
KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
|
KeyPath = GetItemPathW(hwndTV, hItem, &hRoot);
|
||||||
|
|
||||||
if (!KeyPath || !hRoot)
|
if (!KeyPath || !hRoot)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (RegOpenKeyEx(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
|
if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
|
||||||
HeapFree(GetProcessHeap(), 0, KeyPath);
|
HeapFree(GetProcessHeap(), 0, KeyPath);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode,
|
||||||
adjust = 0;
|
adjust = 0;
|
||||||
/* RegEnumValue won't return empty default value, so fake it when dealing with *row,
|
/* RegEnumValue won't return empty default value, so fake it when dealing with *row,
|
||||||
which corresponds to list view rows, not value ids */
|
which corresponds to list view rows, not value ids */
|
||||||
if (ERROR_SUCCESS == RegEnumValue(hKey, 0, valName, &lenName, NULL, NULL, NULL, NULL) && *valName)
|
if (ERROR_SUCCESS == RegEnumValueW(hKey, 0, valName, &lenName, NULL, NULL, NULL, NULL) && *valName)
|
||||||
adjust = 1;
|
adjust = 1;
|
||||||
|
|
||||||
i = (*row)-adjust;
|
i = (*row)-adjust;
|
||||||
|
@ -310,7 +310,7 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode,
|
||||||
DWORD lenValue = 0, type = 0;
|
DWORD lenValue = 0, type = 0;
|
||||||
lenName = KEY_MAX_LEN;
|
lenName = KEY_MAX_LEN;
|
||||||
|
|
||||||
if (ERROR_SUCCESS != RegEnumValue(hKey,
|
if (ERROR_SUCCESS != RegEnumValueW(hKey,
|
||||||
i, valName, &lenName, NULL, &type, NULL, &lenValue))
|
i, valName, &lenName, NULL, &type, NULL, &lenValue))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -323,9 +323,9 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mode & SEARCH_CONTENT) && (type == REG_EXPAND_SZ || type == REG_SZ)) {
|
if ((mode & SEARCH_CONTENT) && (type == REG_EXPAND_SZ || type == REG_SZ)) {
|
||||||
LPTSTR buffer;
|
LPWSTR buffer;
|
||||||
buffer = HeapAlloc(GetProcessHeap(), 0, lenValue);
|
buffer = HeapAlloc(GetProcessHeap(), 0, lenValue);
|
||||||
RegEnumValue(hKey, i, valName, &lenName, NULL, &type, (LPBYTE)buffer, &lenValue);
|
RegEnumValueW(hKey, i, valName, &lenName, NULL, &type, (LPBYTE)buffer, &lenValue);
|
||||||
if (match_string(buffer, sstring, mode)) {
|
if (match_string(buffer, sstring, mode)) {
|
||||||
HeapFree(GetProcessHeap(), 0, buffer);
|
HeapFree(GetProcessHeap(), 0, buffer);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
|
@ -342,7 +342,7 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode, int *row)
|
HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, int *row)
|
||||||
{
|
{
|
||||||
HTREEITEM hTry, hLast;
|
HTREEITEM hTry, hLast;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue