* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-#include <regedit.h>
+#include "regedit.h"
#define RSF_WHOLESTRING 0x00000001
-#define RSF_LOOKATKEYS 0x00000002
+#define RSF_LOOKATKEYS 0x00000002
#define RSF_LOOKATVALUES 0x00000004
#define RSF_LOOKATDATA 0x00000008
#define RSF_MATCHCASE 0x00010000
-static TCHAR s_szFindWhat[256];
-static const TCHAR s_szFindFlags[] = _T("FindFlags");
-static const TCHAR s_szFindFlagsR[] = _T("FindFlagsReactOS");
+static WCHAR s_szFindWhat[256];
+static const WCHAR s_szFindFlags[] = L"FindFlags";
+static const WCHAR s_szFindFlagsR[] = L"FindFlagsReactOS";
static HWND s_hwndAbortDialog;
static BOOL s_bAbort;
static DWORD s_dwFlags;
-static TCHAR s_szName[MAX_PATH];
-static DWORD s_cbName;
-static const TCHAR s_empty[] = {0};
-static const TCHAR s_backslash[] = {'\\', 0};
+static WCHAR s_szName[MAX_PATH];
+static DWORD s_cchName;
+static const WCHAR s_empty[] = L"";
+static const WCHAR s_backslash[] = L"\\";
-extern VOID SetValueName(HWND hwndLV, LPCTSTR pszValueName);
+extern VOID SetValueName(HWND hwndLV, LPCWSTR pszValueName);
BOOL DoEvents(VOID)
{
MSG msg;
- if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
s_bAbort = TRUE;
- if (!IsDialogMessage(s_hwndAbortDialog, &msg))
+ if (!IsDialogMessageW(s_hwndAbortDialog, &msg))
{
TranslateMessage(&msg);
- DispatchMessage(&msg);
+ DispatchMessageW(&msg);
}
}
return s_bAbort;
}
-static LPTSTR lstrstri(LPCTSTR psz1, LPCTSTR psz2)
+static LPWSTR lstrstri(LPCWSTR psz1, LPCWSTR psz2)
{
INT i, cch1, cch2;
- cch1 = lstrlen(psz1);
- cch2 = lstrlen(psz2);
+ cch1 = wcslen(psz1);
+ cch2 = wcslen(psz2);
for(i = 0; i <= cch1 - cch2; i++)
{
- if (CompareString(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
- psz1 + i, cch2, psz2, cch2) == 2)
- return (LPTSTR) (psz1 + i);
+ if (CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
+ psz1 + i, cch2, psz2, cch2) == 2)
+ return (LPWSTR) (psz1 + i);
}
return NULL;
}
-static BOOL CompareName(LPCTSTR pszName1, LPCTSTR pszName2)
+static BOOL CompareName(LPCWSTR pszName1, LPCWSTR pszName2)
{
if (s_dwFlags & RSF_WHOLESTRING)
{
if (s_dwFlags & RSF_MATCHCASE)
- return lstrcmp(pszName1, pszName2) == 0;
+ return wcscmp(pszName1, pszName2) == 0;
else
- return lstrcmpi(pszName1, pszName2) == 0;
+ return _wcsicmp(pszName1, pszName2) == 0;
}
else
{
if (s_dwFlags & RSF_MATCHCASE)
- return _tcsstr(pszName1, pszName2) != NULL;
+ return wcsstr(pszName1, pszName2) != NULL;
else
return lstrstri(pszName1, pszName2) != NULL;
}
}
-static BOOL
-CompareData(
- DWORD dwType,
- LPCTSTR psz1,
- LPCTSTR psz2)
+/* Do not assume that pch1 is terminated with UNICODE_NULL */
+static BOOL MatchString(LPCWCH pch1, INT cch1, LPCWCH pch2, INT cch2)
{
- INT i, cch1 = lstrlen(psz1), cch2 = lstrlen(psz2);
- if (dwType == REG_SZ || dwType == REG_EXPAND_SZ)
- {
- if (s_dwFlags & RSF_WHOLESTRING)
- {
- if (s_dwFlags & RSF_MATCHCASE)
- return 2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0,
- psz1, cch1, psz2, cch2);
- else
- return 2 == CompareString(LOCALE_SYSTEM_DEFAULT,
- NORM_IGNORECASE, psz1, cch1, psz2, cch2);
- }
+ INT i;
+ DWORD dwNorm = ((s_dwFlags & RSF_MATCHCASE) ? 0 : NORM_IGNORECASE);
- for(i = 0; i <= cch1 - cch2; i++)
- {
- if (s_dwFlags & RSF_MATCHCASE)
- {
- if (2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0,
- psz1 + i, cch2, psz2, cch2))
- return TRUE;
- }
- else
- {
- if (2 == CompareString(LOCALE_SYSTEM_DEFAULT,
- NORM_IGNORECASE, psz1 + i, cch2, psz2, cch2))
- return TRUE;
- }
- }
+ if (s_dwFlags & RSF_WHOLESTRING)
+ return 2 == CompareStringW(LOCALE_SYSTEM_DEFAULT, dwNorm, pch1, cch1, pch2, cch2);
+
+ if (cch1 < cch2)
+ return FALSE;
+
+ for (i = 0; i <= cch1 - cch2; i++)
+ {
+ if (2 == CompareStringW(LOCALE_SYSTEM_DEFAULT, dwNorm, pch1 + i, cch2, pch2, cch2))
+ return TRUE;
}
+
+ return FALSE;
+}
+
+static BOOL MatchData(DWORD dwType, LPCVOID pv1, DWORD cb1)
+{
+ if (dwType == REG_SZ || dwType == REG_EXPAND_SZ || dwType == REG_MULTI_SZ)
+ return MatchString(pv1, (INT)(cb1 / sizeof(WCHAR)), s_szFindWhat, lstrlenW(s_szFindWhat));
+
return FALSE;
}
int compare(const void *x, const void *y)
{
- const LPCTSTR *a = (const LPCTSTR *)x;
- const LPCTSTR *b = (const LPCTSTR *)y;
- return lstrcmpi(*a, *b);
+ const LPCWSTR *a = (const LPCWSTR *)x;
+ const LPCWSTR *b = (const LPCWSTR *)y;
+ return _wcsicmp(*a, *b);
}
BOOL RegFindRecurse(
HKEY hKey,
- LPCTSTR pszSubKey,
- LPCTSTR pszValueName,
- LPTSTR *ppszFoundSubKey,
- LPTSTR *ppszFoundValueName)
+ LPCWSTR pszSubKey,
+ LPCWSTR pszValueName,
+ LPWSTR *ppszFoundSubKey,
+ LPWSTR *ppszFoundValueName)
{
HKEY hSubKey;
LONG lResult;
- TCHAR szSubKey[MAX_PATH];
+ WCHAR szSubKey[MAX_PATH];
DWORD i, c, cb, type;
- BOOL fPast = FALSE;
- LPTSTR *ppszNames = NULL;
+ BOOL fPast;
+ LPWSTR *ppszNames = NULL;
LPBYTE pb = NULL;
if (DoEvents())
return FALSE;
- lstrcpy(szSubKey, pszSubKey);
+ if(wcslen(pszSubKey) >= _countof(szSubKey))
+ return FALSE;
+
+ StringCbCopyW(szSubKey, sizeof(szSubKey), pszSubKey);
hSubKey = NULL;
- lResult = RegOpenKeyEx(hKey, szSubKey, 0, KEY_ALL_ACCESS, &hSubKey);
+ lResult = RegOpenKeyExW(hKey, szSubKey, 0, KEY_ALL_ACCESS, &hSubKey);
if (lResult != ERROR_SUCCESS)
return FALSE;
- if (pszValueName == NULL)
- pszValueName = s_empty;
-
- lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL,
+ lResult = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL,
&c, NULL, NULL, NULL, NULL);
if (lResult != ERROR_SUCCESS)
goto err;
- ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR));
+ ppszNames = (LPWSTR *) malloc(c * sizeof(LPWSTR));
if (ppszNames == NULL)
goto err;
- ZeroMemory(ppszNames, c * sizeof(LPTSTR));
+ ZeroMemory(ppszNames, c * sizeof(LPWSTR));
+ /* Retrieve the value names associated with the current key */
for(i = 0; i < c; i++)
{
if (DoEvents())
goto err;
- s_cbName = MAX_PATH * sizeof(TCHAR);
- lResult = RegEnumValue(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
+ s_cchName = _countof(s_szName);
+ lResult = RegEnumValueW(hSubKey, i, s_szName, &s_cchName, NULL, NULL,
NULL, &cb);
if (lResult == ERROR_NO_MORE_ITEMS)
{
}
if (lResult != ERROR_SUCCESS)
goto err;
- if (s_cbName >= MAX_PATH * sizeof(TCHAR))
+ if (s_cchName >= _countof(s_szName))
continue;
- ppszNames[i] = _tcsdup(s_szName);
+ ppszNames[i] = _wcsdup(s_szName);
}
- qsort(ppszNames, c, sizeof(LPTSTR), compare);
+ qsort(ppszNames, c, sizeof(LPWSTR), compare);
- for(i = 0; i < c; i++)
+ /* If pszValueName is NULL, the function will search for all values within the key */
+ fPast = (pszValueName == NULL);
+
+ /* Search within the values */
+ for (i = 0; i < c; i++)
{
if (DoEvents())
goto err;
- if (!fPast && lstrcmpi(ppszNames[i], pszValueName) == 0)
+ if (!fPast && _wcsicmp(ppszNames[i], pszValueName) == 0)
{
fPast = TRUE;
continue;
if ((s_dwFlags & RSF_LOOKATVALUES) &&
CompareName(ppszNames[i], s_szFindWhat))
{
- *ppszFoundSubKey = _tcsdup(szSubKey);
- if (ppszNames[i][0] == 0)
- *ppszFoundValueName = NULL;
- else
- *ppszFoundValueName = _tcsdup(ppszNames[i]);
+ *ppszFoundSubKey = _wcsdup(szSubKey);
+ *ppszFoundValueName = _wcsdup(ppszNames[i]);
goto success;
}
- lResult = RegQueryValueEx(hSubKey, ppszNames[i], NULL, &type,
+ lResult = RegQueryValueExW(hSubKey, ppszNames[i], NULL, &type,
NULL, &cb);
if (lResult != ERROR_SUCCESS)
goto err;
pb = malloc(cb);
if (pb == NULL)
goto err;
- lResult = RegQueryValueEx(hSubKey, ppszNames[i], NULL, &type,
+ lResult = RegQueryValueExW(hSubKey, ppszNames[i], NULL, &type,
pb, &cb);
if (lResult != ERROR_SUCCESS)
goto err;
- if ((s_dwFlags & RSF_LOOKATDATA) &&
- CompareData(type, (LPTSTR) pb, s_szFindWhat))
+ if ((s_dwFlags & RSF_LOOKATDATA) && MatchData(type, pb, cb))
{
- *ppszFoundSubKey = _tcsdup(szSubKey);
- if (ppszNames[i][0] == 0)
- *ppszFoundValueName = NULL;
- else
- *ppszFoundValueName = _tcsdup(ppszNames[i]);
+ *ppszFoundSubKey = _wcsdup(szSubKey);
+ *ppszFoundValueName = _wcsdup(ppszNames[i]);
goto success;
}
free(pb);
}
ppszNames = NULL;
- lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
+ /* Retrieve the number of sub-keys */
+ lResult = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
if (lResult != ERROR_SUCCESS)
goto err;
- ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR));
+ ppszNames = (LPWSTR *) malloc(c * sizeof(LPWSTR));
if (ppszNames == NULL)
goto err;
- ZeroMemory(ppszNames, c * sizeof(LPTSTR));
+ ZeroMemory(ppszNames, c * sizeof(LPWSTR));
+ /* Retrieve the names of the sub-keys */
for(i = 0; i < c; i++)
{
if (DoEvents())
goto err;
- s_cbName = MAX_PATH * sizeof(TCHAR);
- lResult = RegEnumKeyEx(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
+ s_cchName = _countof(s_szName);
+ lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cchName, NULL, NULL,
NULL, NULL);
if (lResult == ERROR_NO_MORE_ITEMS)
{
}
if (lResult != ERROR_SUCCESS)
goto err;
- if (s_cbName >= MAX_PATH * sizeof(TCHAR))
+ if (s_cchName >= _countof(s_szName))
continue;
- ppszNames[i] = _tcsdup(s_szName);
+ ppszNames[i] = _wcsdup(s_szName);
}
- qsort(ppszNames, c, sizeof(LPTSTR), compare);
+ qsort(ppszNames, c, sizeof(LPWSTR), compare);
+ /* Search within the sub-keys */
for(i = 0; i < c; i++)
{
if (DoEvents())
CompareName(ppszNames[i], s_szFindWhat))
{
*ppszFoundSubKey = malloc(
- (lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) *
- sizeof(TCHAR));
+ (wcslen(szSubKey) + wcslen(ppszNames[i]) + 2) *
+ sizeof(WCHAR));
if (*ppszFoundSubKey == NULL)
goto err;
if (szSubKey[0])
{
- lstrcpy(*ppszFoundSubKey, szSubKey);
- lstrcatW(*ppszFoundSubKey, s_backslash);
+ wcscpy(*ppszFoundSubKey, szSubKey);
+ wcscat(*ppszFoundSubKey, s_backslash);
}
else
**ppszFoundSubKey = 0;
- lstrcatW(*ppszFoundSubKey, ppszNames[i]);
+ wcscat(*ppszFoundSubKey, ppszNames[i]);
*ppszFoundValueName = NULL;
goto success;
}
+ /* Search within the value entries of the sub-key */
if (RegFindRecurse(hSubKey, ppszNames[i], NULL, ppszFoundSubKey,
ppszFoundValueName))
{
- LPTSTR psz = *ppszFoundSubKey;
- *ppszFoundSubKey = malloc(
- (lstrlen(szSubKey) + lstrlen(psz) + 2) * sizeof(TCHAR));
+ LPWSTR psz = *ppszFoundSubKey;
+ SIZE_T cbFoundSubKey = (wcslen(szSubKey) + wcslen(psz) + 2) * sizeof(WCHAR);
+ *ppszFoundSubKey = malloc(cbFoundSubKey);
if (*ppszFoundSubKey == NULL)
goto err;
if (szSubKey[0])
{
- lstrcpy(*ppszFoundSubKey, szSubKey);
- lstrcatW(*ppszFoundSubKey, s_backslash);
+ StringCbCopyW(*ppszFoundSubKey, cbFoundSubKey, szSubKey);
+ StringCbCatW(*ppszFoundSubKey, cbFoundSubKey, s_backslash);
}
else
**ppszFoundSubKey = 0;
- lstrcatW(*ppszFoundSubKey, psz);
+ wcscat(*ppszFoundSubKey, psz);
free(psz);
goto success;
}
BOOL RegFindWalk(
HKEY * phKey,
- LPCTSTR pszSubKey,
- LPCTSTR pszValueName,
- LPTSTR *ppszFoundSubKey,
- LPTSTR *ppszFoundValueName)
+ LPCWSTR pszSubKey,
+ LPCWSTR pszValueName,
+ LPWSTR *ppszFoundSubKey,
+ LPWSTR *ppszFoundValueName)
{
LONG lResult;
DWORD i, c;
HKEY hBaseKey, hSubKey;
- TCHAR szKeyName[MAX_PATH];
- TCHAR szSubKey[MAX_PATH];
- LPTSTR pch;
- BOOL fPast;
- LPTSTR *ppszNames = NULL;
+ WCHAR szKeyName[MAX_PATH];
+ WCHAR szSubKey[MAX_PATH];
+ LPWSTR pch;
+ BOOL fPast, fKeyMatched;
+ LPWSTR *ppszNames = NULL;
hBaseKey = *phKey;
+
+ if (wcslen(pszSubKey) >= _countof(szSubKey))
+ return FALSE;
+
if (RegFindRecurse(hBaseKey, pszSubKey, pszValueName, ppszFoundSubKey,
ppszFoundValueName))
return TRUE;
- if (lstrlen(pszSubKey) >= MAX_PATH)
- return FALSE;
-
- lstrcpy(szSubKey, pszSubKey);
+ StringCbCopyW(szSubKey, sizeof(szSubKey), pszSubKey);
while(szSubKey[0] != 0)
{
if (DoEvents())
return FALSE;
- pch = _tcsrchr(szSubKey, _T('\\'));
+ pch = wcsrchr(szSubKey, L'\\');
if (pch == NULL)
{
- lstrcpy(szKeyName, szSubKey);
+ wcscpy(szKeyName, szSubKey);
szSubKey[0] = 0;
hSubKey = hBaseKey;
}
else
{
- lstrcpyn(szKeyName, pch + 1, MAX_PATH);
+ lstrcpynW(szKeyName, pch + 1, MAX_PATH);
*pch = 0;
- lResult = RegOpenKeyEx(hBaseKey, szSubKey, 0, KEY_ALL_ACCESS,
+ lResult = RegOpenKeyExW(hBaseKey, szSubKey, 0, KEY_ALL_ACCESS,
&hSubKey);
if (lResult != ERROR_SUCCESS)
return FALSE;
}
- lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
+ lResult = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
if (lResult != ERROR_SUCCESS)
goto err;
- ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR));
+ ppszNames = (LPWSTR *) malloc(c * sizeof(LPWSTR));
if (ppszNames == NULL)
goto err;
- ZeroMemory(ppszNames, c * sizeof(LPTSTR));
+ ZeroMemory(ppszNames, c * sizeof(LPWSTR));
for(i = 0; i < c; i++)
{
if (DoEvents())
goto err;
- s_cbName = MAX_PATH * sizeof(TCHAR);
- lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cbName,
+ s_cchName = _countof(s_szName);
+ lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cchName,
NULL, NULL, NULL, NULL);
if (lResult == ERROR_NO_MORE_ITEMS)
{
}
if (lResult != ERROR_SUCCESS)
break;
- ppszNames[i] = _tcsdup(s_szName);
+ ppszNames[i] = _wcsdup(s_szName);
}
- qsort(ppszNames, c, sizeof(LPTSTR), compare);
+ qsort(ppszNames, c, sizeof(LPWSTR), compare);
fPast = FALSE;
for(i = 0; i < c; i++)
if (DoEvents())
goto err;
- if (!fPast && lstrcmpi(ppszNames[i], szKeyName) == 0)
+ if (!fPast && _wcsicmp(ppszNames[i], szKeyName) == 0)
{
fPast = TRUE;
continue;
CompareName(ppszNames[i], s_szFindWhat))
{
*ppszFoundSubKey = malloc(
- (lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) *
- sizeof(TCHAR));
+ (wcslen(szSubKey) + wcslen(ppszNames[i]) + 2) *
+ sizeof(WCHAR));
if (*ppszFoundSubKey == NULL)
goto err;
if (szSubKey[0])
{
- lstrcpy(*ppszFoundSubKey, szSubKey);
- lstrcatW(*ppszFoundSubKey, s_backslash);
+ wcscpy(*ppszFoundSubKey, szSubKey);
+ wcscat(*ppszFoundSubKey, s_backslash);
}
else
**ppszFoundSubKey = 0;
- lstrcatW(*ppszFoundSubKey, ppszNames[i]);
+ wcscat(*ppszFoundSubKey, ppszNames[i]);
*ppszFoundValueName = NULL;
goto success;
}
- if (RegFindRecurse(hSubKey, ppszNames[i], NULL,
+ fKeyMatched = (_wcsicmp(ppszNames[i], szKeyName) == 0);
+ if (RegFindRecurse(hSubKey, ppszNames[i], (fKeyMatched ? pszValueName : NULL),
ppszFoundSubKey, ppszFoundValueName))
{
- LPTSTR psz = *ppszFoundSubKey;
- *ppszFoundSubKey = malloc(
- (lstrlen(szSubKey) + lstrlen(psz) + 2) *
- sizeof(TCHAR));
+ LPWSTR psz = *ppszFoundSubKey;
+ SIZE_T cbFoundSubKey = (wcslen(szSubKey) + wcslen(psz) + 2) * sizeof(WCHAR);
+ *ppszFoundSubKey = malloc(cbFoundSubKey);
if (*ppszFoundSubKey == NULL)
goto err;
if (szSubKey[0])
{
- lstrcpy(*ppszFoundSubKey, szSubKey);
- lstrcatW(*ppszFoundSubKey, s_backslash);
+ StringCbCopyW(*ppszFoundSubKey, cbFoundSubKey, szSubKey);
+ StringCbCatW(*ppszFoundSubKey, cbFoundSubKey, s_backslash);
}
else
**ppszFoundSubKey = 0;
- lstrcatW(*ppszFoundSubKey, psz);
+ wcscat(*ppszFoundSubKey, psz);
free(psz);
goto success;
}
DWORD dwType, dwValue, cbData;
DWORD dwFlags = RSF_LOOKATKEYS | RSF_LOOKATVALUES | RSF_LOOKATDATA;
- if (RegOpenKey(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
+ if (RegOpenKeyW(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
{
/* Retrieve flags from registry key */
cbData = sizeof(dwValue);
- if (RegQueryValueEx(hKey, s_szFindFlags, NULL, &dwType, (LPBYTE) &dwValue, &cbData) == ERROR_SUCCESS)
+ if (RegQueryValueExW(hKey, s_szFindFlags, NULL, &dwType, (LPBYTE) &dwValue, &cbData) == ERROR_SUCCESS)
{
if (dwType == REG_DWORD)
dwFlags = (dwFlags & ~0x0000FFFF) | ((dwValue & 0x0000FFFF) << 0);
/* Retrieve ReactOS Regedit specific flags from registry key */
cbData = sizeof(dwValue);
- if (RegQueryValueEx(hKey, s_szFindFlagsR, NULL, &dwType, (LPBYTE) &dwValue, &cbData) == ERROR_SUCCESS)
+ if (RegQueryValueExW(hKey, s_szFindFlagsR, NULL, &dwType, (LPBYTE) &dwValue, &cbData) == ERROR_SUCCESS)
{
if (dwType == REG_DWORD)
dwFlags = (dwFlags & ~0xFFFF0000) | ((dwValue & 0x0000FFFF) << 16);
DWORD dwDisposition;
DWORD dwData;
- if (RegCreateKeyEx(HKEY_CURRENT_USER, g_szGeneralRegKey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
+ if (RegCreateKeyExW(HKEY_CURRENT_USER, g_szGeneralRegKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
{
dwData = (dwFlags >> 0) & 0x0000FFFF;
- RegSetValueEx(hKey, s_szFindFlags, 0, REG_DWORD, (const BYTE *) &dwData, sizeof(dwData));
+ RegSetValueExW(hKey, s_szFindFlags, 0, REG_DWORD, (const BYTE *) &dwData, sizeof(dwData));
dwData = (dwFlags >> 16) & 0x0000FFFF;
- RegSetValueEx(hKey, s_szFindFlagsR, 0, REG_DWORD, (const BYTE *) &dwData, sizeof(dwData));
+ RegSetValueExW(hKey, s_szFindFlagsR, 0, REG_DWORD, (const BYTE *) &dwData, sizeof(dwData));
RegCloseKey(hKey);
}
BOOL FindNext(HWND hWnd)
{
HKEY hKeyRoot;
- LPCTSTR pszKeyPath;
+ LPCWSTR pszKeyPath;
BOOL fSuccess;
- TCHAR szFullKey[512];
- LPCTSTR pszValueName;
- LPTSTR pszFoundSubKey, pszFoundValueName;
+ WCHAR szFullKey[512];
+ LPCWSTR pszValueName;
+ LPWSTR pszFoundSubKey, pszFoundValueName;
- if (_tcslen(s_szFindWhat) == 0)
+ if (wcslen(s_szFindWhat) == 0)
{
FindDialog(hWnd);
return TRUE;
}
/* Create abort find dialog */
- s_hwndAbortDialog = CreateDialog(GetModuleHandle(NULL),
- MAKEINTRESOURCE(IDD_FINDING), hWnd, AbortFindDialogProc);
+ s_hwndAbortDialog = CreateDialogW(GetModuleHandle(NULL),
+ MAKEINTRESOURCEW(IDD_FINDING), hWnd, AbortFindDialogProc);
if (s_hwndAbortDialog)
{
ShowWindow(s_hwndAbortDialog, SW_SHOW);
if (fSuccess)
{
- GetKeyName(szFullKey, COUNT_OF(szFullKey), hKeyRoot, pszFoundSubKey);
+ GetKeyName(szFullKey, ARRAY_SIZE(szFullKey), hKeyRoot, pszFoundSubKey);
SelectNode(g_pChildWnd->hTreeWnd, szFullKey);
- SetValueName(g_pChildWnd->hListWnd, pszFoundValueName);
free(pszFoundSubKey);
- free(pszFoundValueName);
- SetFocus(g_pChildWnd->hListWnd);
+
+ if (pszFoundValueName != NULL)
+ {
+ SetValueName(g_pChildWnd->hListWnd, pszFoundValueName);
+ free(pszFoundValueName);
+ SetFocus(g_pChildWnd->hListWnd);
+ }
+ else
+ {
+ SetFocus(g_pChildWnd->hTreeWnd);
+ }
}
return fSuccess || s_bAbort;
}
HWND hControl;
LONG lStyle;
DWORD dwFlags;
- static TCHAR s_szSavedFindValue[256];
+ static WCHAR s_szSavedFindValue[256];
switch(uMsg)
{
hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS);
if (hControl)
- SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATKEYS) ? TRUE : FALSE, 0);
+ SendMessageW(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATKEYS) ? TRUE : FALSE, 0);
hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES);
if (hControl)
- SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATVALUES) ? TRUE : FALSE, 0);
+ SendMessageW(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATVALUES) ? TRUE : FALSE, 0);
hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA);
if (hControl)
- SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATDATA) ? TRUE : FALSE, 0);
+ SendMessageW(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATDATA) ? TRUE : FALSE, 0);
/* Match whole string */
hControl = GetDlgItem(hDlg, IDC_MATCHSTRING);
if (hControl)
- SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_WHOLESTRING) ? TRUE : FALSE, 0);
+ SendMessageW(hControl, BM_SETCHECK, (dwFlags & RSF_WHOLESTRING) ? TRUE : FALSE, 0);
/* Case sensitivity */
hControl = GetDlgItem(hDlg, IDC_MATCHCASE);
if (hControl)
- SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_MATCHCASE) ? TRUE : FALSE, 0);
+ SendMessageW(hControl, BM_SETCHECK, (dwFlags & RSF_MATCHCASE) ? TRUE : FALSE, 0);
hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
if (hControl)
{
- SetWindowText(hControl, s_szSavedFindValue);
+ SetWindowTextW(hControl, s_szSavedFindValue);
SetFocus(hControl);
- SendMessage(hControl, EM_SETSEL, 0, -1);
+ SendMessageW(hControl, EM_SETSEL, 0, -1);
}
break;
dwFlags = 0;
hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS);
- if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
+ if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
dwFlags |= RSF_LOOKATKEYS;
hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES);
- if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
+ if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
dwFlags |= RSF_LOOKATVALUES;
hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA);
- if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
+ if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
dwFlags |= RSF_LOOKATDATA;
hControl = GetDlgItem(hDlg, IDC_MATCHSTRING);
- if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
+ if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
dwFlags |= RSF_WHOLESTRING;
hControl = GetDlgItem(hDlg, IDC_MATCHCASE);
- if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
+ if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
dwFlags |= RSF_MATCHCASE;
SetFindFlags(dwFlags);
hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
if (hControl)
- GetWindowText(hControl, s_szFindWhat, sizeof(s_szFindWhat) / sizeof(s_szFindWhat[0]));
+ GetWindowTextW(hControl, s_szFindWhat, ARRAY_SIZE(s_szFindWhat));
EndDialog(hDlg, 1);
break;
switch(LOWORD(wParam))
{
case IDC_FINDWHAT:
- GetWindowText((HWND) lParam, s_szSavedFindValue, sizeof(s_szSavedFindValue) / sizeof(s_szSavedFindValue[0]));
+ GetWindowTextW((HWND) lParam, s_szSavedFindValue, ARRAY_SIZE(s_szSavedFindValue));
hControl = GetDlgItem(hDlg, IDOK);
if (hControl)
{
return iResult;
}
-void FindDialog(HWND hWnd)
+void FindNextMessageBox(HWND hWnd)
{
- if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FIND),
- hWnd, FindDialogProc, 0) != 0)
+ if (!FindNext(hWnd))
{
- if (!FindNext(hWnd))
- {
- TCHAR msg[128], caption[128];
+ WCHAR msg[128], caption[128];
- LoadString(hInst, IDS_FINISHEDFIND, msg, sizeof(msg)/sizeof(TCHAR));
- LoadString(hInst, IDS_APP_TITLE, caption, sizeof(caption)/sizeof(TCHAR));
- MessageBox(0, msg, caption, MB_ICONINFORMATION);
- }
+ LoadStringW(hInst, IDS_FINISHEDFIND, msg, ARRAY_SIZE(msg));
+ LoadStringW(hInst, IDS_APP_TITLE, caption, ARRAY_SIZE(caption));
+ MessageBoxW(hWnd, msg, caption, MB_ICONINFORMATION);
}
}
+void FindDialog(HWND hWnd)
+{
+ if (DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_FIND),
+ hWnd, FindDialogProc, 0) != 0)
+ {
+ FindNextMessageBox(hWnd);
+ }
+}