[REGEDIT]

- Convert the application's code to UNICODE
- But the regproc.c's code is untouched (apart from the pseudo-error messages issued with fprintf)

svn path=/trunk/; revision=57471
This commit is contained in:
Hermès Bélusca-Maïto 2012-10-03 22:42:34 +00:00
parent 70e6572e30
commit c23873e5cb
20 changed files with 1239 additions and 1341 deletions

View file

@ -23,7 +23,9 @@
void ShowAboutBox(HWND hWnd)
{
TCHAR AppStr[255];
LoadString(hInst, IDS_APP_TITLE, AppStr, COUNT_OF(AppStr));
ShellAbout(hWnd, AppStr, _T(""), LoadIcon(hInst, MAKEINTRESOURCE(IDI_REGEDIT)));
WCHAR AppStr[255];
LoadStringW(hInst, IDS_APP_TITLE, AppStr, COUNT_OF(AppStr));
ShellAboutW(hWnd, AppStr, L"", LoadIconW(hInst, MAKEINTRESOURCEW(IDI_REGEDIT)));
}
/* EOF */

View file

@ -24,17 +24,18 @@ ChildWnd* g_pChildWnd;
static int last_split;
HBITMAP SizingPattern = 0;
HBRUSH SizingBrush = 0;
static TCHAR Suggestions[256];
static WCHAR Suggestions[256];
extern LPCTSTR get_root_key_name(HKEY hRootKey)
extern LPCWSTR get_root_key_name(HKEY hRootKey)
{
if (hRootKey == HKEY_CLASSES_ROOT) return _T("HKEY_CLASSES_ROOT");
if (hRootKey == HKEY_CURRENT_USER) return _T("HKEY_CURRENT_USER");
if (hRootKey == HKEY_LOCAL_MACHINE) return _T("HKEY_LOCAL_MACHINE");
if (hRootKey == HKEY_USERS) return _T("HKEY_USERS");
if (hRootKey == HKEY_CURRENT_CONFIG) return _T("HKEY_CURRENT_CONFIG");
if (hRootKey == HKEY_DYN_DATA) return _T("HKEY_DYN_DATA");
return _T("UKNOWN HKEY, PLEASE REPORT");
if (hRootKey == HKEY_CLASSES_ROOT) return L"HKEY_CLASSES_ROOT";
if (hRootKey == HKEY_CURRENT_USER) return L"HKEY_CURRENT_USER";
if (hRootKey == HKEY_LOCAL_MACHINE) return L"HKEY_LOCAL_MACHINE";
if (hRootKey == HKEY_USERS) return L"HKEY_USERS";
if (hRootKey == HKEY_CURRENT_CONFIG) return L"HKEY_CURRENT_CONFIG";
if (hRootKey == HKEY_DYN_DATA) return L"HKEY_DYN_DATA";
return L"UKNOWN HKEY, PLEASE REPORT";
}
extern void ResizeWnd(int cx, int cy)
@ -127,7 +128,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HTREEITEM hSelection;
HKEY hRootKey;
LPCTSTR keyPath, s;
LPCWSTR keyPath, s;
WORD wID = LOWORD(wParam);
UNREFERENCED_PARAMETER(message);
@ -179,7 +180,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ID_EDIT_NEW_STRINGVALUE:
case ID_EDIT_NEW_BINARYVALUE:
case ID_EDIT_NEW_DWORDVALUE:
SendMessage(hFrameWnd, WM_COMMAND, wParam, lParam);
SendMessageW(hFrameWnd, WM_COMMAND, wParam, lParam);
break;
case ID_SWITCH_PANELS:
g_pChildWnd->nFocusPanel = !g_pChildWnd->nFocusPanel;
@ -192,7 +193,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
while(wID > ID_TREE_SUGGESTION_MIN)
{
if (*s)
s += _tcslen(s) + 1;
s += wcslen(s) + 1;
wID--;
}
SelectNode(g_pChildWnd->hTreeWnd, s);
@ -208,13 +209,13 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
* Key suggestion
*/
#define MIN(a,b) ((a < b) ? (a) : (b))
#define MIN(a,b) ((a < b) ? (a) : (b))
static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions,
static void SuggestKeys(HKEY hRootKey, LPCWSTR pszKeyPath, LPWSTR pszSuggestions,
size_t iSuggestionsLength)
{
TCHAR szBuffer[256];
TCHAR szLastFound[256];
WCHAR szBuffer[256];
WCHAR szLastFound[256];
size_t i;
HKEY hOtherKey, hSubKey;
BOOL bFound;
@ -223,7 +224,7 @@ static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions
iSuggestionsLength--;
/* Are we a root key in HKEY_CLASSES_ROOT? */
if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !_tcschr(pszKeyPath, TEXT('\\')))
if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !wcschr(pszKeyPath, L'\\'))
{
do
{
@ -235,23 +236,23 @@ static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions
{
/* Sanity check this key; it cannot be empty, nor can it be a
* loop back */
if ((szBuffer[0] != '\0') && _tcsicmp(szBuffer, pszKeyPath))
if ((szBuffer[0] != L'\0') && wcsicmp(szBuffer, pszKeyPath))
{
if (RegOpenKey(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS)
if (RegOpenKeyW(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS)
{
lstrcpyn(pszSuggestions, TEXT("HKCR\\"), (int) iSuggestionsLength);
i = _tcslen(pszSuggestions);
wcsncpy(pszSuggestions, L"HKCR\\", (int) iSuggestionsLength);
i = wcslen(pszSuggestions);
pszSuggestions += i;
iSuggestionsLength -= i;
lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength);
i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength);
wcsncpy(pszSuggestions, szBuffer, (int) iSuggestionsLength);
i = MIN(wcslen(pszSuggestions) + 1, iSuggestionsLength);
pszSuggestions += i;
iSuggestionsLength -= i;
RegCloseKey(hOtherKey);
bFound = TRUE;
_tcscpy(szLastFound, szBuffer);
wcscpy(szLastFound, szBuffer);
pszKeyPath = szLastFound;
}
}
@ -260,18 +261,18 @@ static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions
while(bFound && (iSuggestionsLength > 0));
/* Check CLSID key */
if (RegOpenKey(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS)
if (RegOpenKeyW(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS)
{
if (QueryStringValue(hSubKey, TEXT("CLSID"), NULL, szBuffer,
if (QueryStringValue(hSubKey, L"CLSID", NULL, szBuffer,
COUNT_OF(szBuffer)) == ERROR_SUCCESS)
{
lstrcpyn(pszSuggestions, TEXT("HKCR\\CLSID\\"), (int) iSuggestionsLength);
i = _tcslen(pszSuggestions);
wcsncpy(pszSuggestions, L"HKCR\\CLSID\\", (int)iSuggestionsLength);
i = wcslen(pszSuggestions);
pszSuggestions += i;
iSuggestionsLength -= i;
lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength);
i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength);
wcsncpy(pszSuggestions, szBuffer, (int)iSuggestionsLength);
i = MIN(wcslen(pszSuggestions) + 1, iSuggestionsLength);
pszSuggestions += i;
iSuggestionsLength -= i;
}
@ -284,7 +285,7 @@ static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions
LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
WNDPROC oldwndproc;
static TCHAR s_szNode[256];
static WCHAR s_szNode[256];
oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWL_USERDATA);
switch (uMsg)
@ -292,7 +293,7 @@ LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_KEYUP:
if (wParam == VK_RETURN)
{
GetWindowText(hwnd, s_szNode, COUNT_OF(s_szNode));
GetWindowTextW(hwnd, s_szNode, COUNT_OF(s_szNode));
SelectNode(g_pChildWnd->hTreeWnd, s_szNode);
}
break;
@ -323,22 +324,22 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
{
WNDPROC oldproc;
HFONT hFont;
TCHAR buffer[MAX_PATH];
WCHAR buffer[MAX_PATH];
/* load "My Computer" string */
LoadString(hInst, IDS_MY_COMPUTER, buffer, COUNT_OF(buffer));
LoadStringW(hInst, IDS_MY_COMPUTER, buffer, COUNT_OF(buffer));
g_pChildWnd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ChildWnd));
if (!g_pChildWnd) return 0;
_tcsncpy(g_pChildWnd->szPath, buffer, MAX_PATH);
wcsncpy(g_pChildWnd->szPath, buffer, MAX_PATH);
g_pChildWnd->nSplitPos = 250;
g_pChildWnd->hWnd = hWnd;
g_pChildWnd->hAddressBarWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, (HMENU)0, hInst, 0);
g_pChildWnd->hAddressBtnWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Button"), _T("»"), WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP | BS_DEFPUSHBUTTON,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, (HMENU)0, hInst, 0);
g_pChildWnd->hAddressBarWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Edit", NULL, WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, (HMENU)0, hInst, 0);
g_pChildWnd->hAddressBtnWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Button", L"»", WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP | BS_DEFPUSHBUTTON,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, (HMENU)0, hInst, 0);
g_pChildWnd->hTreeWnd = CreateTreeView(hWnd, g_pChildWnd->szPath, (HMENU) TREE_WINDOW);
g_pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW/*, g_pChildWnd->szPath*/);
SetFocus(g_pChildWnd->hTreeWnd);
@ -347,14 +348,14 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
if ((g_pChildWnd->hAddressBarWnd) && (g_pChildWnd->hAddressBtnWnd))
{
hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
SendMessage(g_pChildWnd->hAddressBarWnd,
WM_SETFONT,
(WPARAM)hFont,
0);
SendMessage(g_pChildWnd->hAddressBtnWnd,
WM_SETFONT,
(WPARAM)hFont,
0);
SendMessageW(g_pChildWnd->hAddressBarWnd,
WM_SETFONT,
(WPARAM)hFont,
0);
SendMessageW(g_pChildWnd->hAddressBtnWnd,
WM_SETFONT,
(WPARAM)hFont,
0);
}
/* Subclass the AddressBar */
oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWL_WNDPROC);
@ -365,7 +366,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_COMMAND:
if(HIWORD(wParam) == BN_CLICKED)
{
PostMessage(g_pChildWnd->hAddressBarWnd, WM_KEYUP, VK_RETURN, 0);
PostMessageW(g_pChildWnd->hAddressBarWnd, WM_KEYUP, VK_RETURN, 0);
}
if (!_CmdWndProc(hWnd, message, wParam, lParam))
@ -384,7 +385,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
ScreenToClient(hWnd, &pt);
if (pt.x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1)
{
SetCursor(LoadCursor(0, IDC_SIZEWE));
SetCursor(LoadCursorW(0, IDC_SIZEWE));
return TRUE;
}
}
@ -434,7 +435,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
ResizeWnd(rt.right, rt.bottom);
last_split = -1;
ReleaseCapture();
SetCursor(LoadCursor(0, IDC_ARROW));
SetCursor(LoadCursorW(0, IDC_ARROW));
}
break;
@ -493,8 +494,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
case TVN_SELCHANGED:
{
LPCTSTR keyPath, rootName;
LPTSTR fullPath;
LPCWSTR keyPath, rootName;
LPWSTR fullPath;
HKEY hRootKey;
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey);
@ -502,29 +503,29 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
{
RefreshListView(g_pChildWnd->hListWnd, hRootKey, keyPath);
rootName = get_root_key_name(hRootKey);
fullPath = HeapAlloc(GetProcessHeap(), 0, (_tcslen(rootName) + 1 + _tcslen(keyPath) + 1) * sizeof(TCHAR));
fullPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(rootName) + 1 + wcslen(keyPath) + 1) * sizeof(WCHAR));
if (fullPath)
{
/* set (correct) the address bar text */
if(keyPath[0] != '\0')
_stprintf(fullPath, _T("%s\\%s"), rootName, keyPath);
if(keyPath[0] != L'\0')
swprintf(fullPath, L"%s\\%s", rootName, keyPath);
else
fullPath = _tcscpy(fullPath, rootName);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
SendMessage(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
fullPath = wcscpy(fullPath, rootName);
SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
SendMessageW(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
HeapFree(GetProcessHeap(), 0, fullPath);
/* disable hive manipulation items temporarily (enable only if necessary) */
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED);
/* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
if (!(_tcsicmp(rootName, TEXT("HKEY_LOCAL_MACHINE")) &&
_tcsicmp(rootName, TEXT("HKEY_USERS"))))
if (!(wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") &&
wcsicmp(rootName, L"HKEY_USERS")))
{
// enable the unload menu item if at the root
// otherwise enable the load menu item if there is no slash in keyPath (ie. immediate child selected)
if(keyPath[0] == '\0')
if(keyPath[0] == L'\0')
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED);
else if(!_tcschr(keyPath, _T('\\')))
else if(!wcschr(keyPath, L'\\'))
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED);
}
}
@ -540,26 +541,26 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
/* cancel label edit for rootkeys */
ptvdi = (LPNMTVDISPINFO) lParam;
if (!TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem) ||
!TreeView_GetParent(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem)))
!TreeView_GetParent(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem)))
return TRUE;
break;
}
case TVN_ENDLABELEDIT:
{
LPCTSTR keyPath;
LPCWSTR keyPath;
HKEY hRootKey;
HKEY hKey = NULL;
LPNMTVDISPINFO ptvdi;
LONG lResult = TRUE;
TCHAR szBuffer[MAX_PATH];
WCHAR szBuffer[MAX_PATH];
ptvdi = (LPNMTVDISPINFO) lParam;
if (ptvdi->item.pszText)
{
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey);
_sntprintf(szBuffer, COUNT_OF(szBuffer), _T("%s\\%s"), keyPath, ptvdi->item.pszText);
_snwprintf(szBuffer, COUNT_OF(szBuffer), L"%s\\%s", keyPath, ptvdi->item.pszText);
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey);
if (RegOpenKeyEx(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
if (RegOpenKeyExW(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
lResult = FALSE;
RegCloseKey(hKey);
@ -615,7 +616,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
if (i != -1)
{
rc.left = LVIR_BOUNDS;
SendMessage(g_pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc);
SendMessageW(g_pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc);
pt.x = rc.left + 8;
pt.y = rc.top + 8;
}
@ -648,10 +649,10 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
HMENU hContextMenu;
TVITEM item;
MENUITEMINFO mii;
TCHAR resource[256];
TCHAR buffer[256];
LPTSTR s;
LPCTSTR keyPath;
WCHAR resource[256];
WCHAR buffer[256];
LPWSTR s;
LPCWSTR keyPath;
HKEY hRootKey;
int iLastPos;
WORD wID;
@ -693,13 +694,13 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
(void)TreeView_GetItem(g_pChildWnd->hTreeWnd, &item);
/* Set the Expand/Collapse menu item appropriately */
LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, COUNT_OF(buffer));
LoadStringW(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, COUNT_OF(buffer));
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID;
mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED;
mii.wID = (item.state & TVIS_EXPANDED) ? ID_TREE_COLLAPSEBRANCH : ID_TREE_EXPANDBRANCH;
mii.dwTypeData = (LPTSTR) buffer;
mii.dwTypeData = (LPWSTR) buffer;
SetMenuItemInfo(hContextMenu, 0, TRUE, &mii);
/* Remove any existing suggestions */
@ -725,13 +726,13 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
{
AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL);
LoadString(hInst, IDS_GOTO_SUGGESTED_KEY, resource, COUNT_OF(resource));
LoadStringW(hInst, IDS_GOTO_SUGGESTED_KEY, resource, COUNT_OF(resource));
s = Suggestions;
wID = ID_TREE_SUGGESTION_MIN;
while(*s && (wID <= ID_TREE_SUGGESTION_MAX))
{
_sntprintf(buffer, COUNT_OF(buffer), resource, s);
_snwprintf(buffer, COUNT_OF(buffer), resource, s);
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
@ -740,7 +741,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
mii.dwTypeData = buffer;
InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii);
s += _tcslen(s) + 1;
s += wcslen(s) + 1;
}
}
TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, g_pChildWnd->hWnd, NULL);
@ -757,7 +758,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
/* fall through */
default:
def:
return DefWindowProc(hWnd, message, wParam, lParam);
return DefWindowProcW(hWnd, message, wParam, lParam);
}
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -21,56 +21,56 @@
#include <regedit.h>
int ErrorMessageBox(HWND hWnd, LPCTSTR lpTitle, DWORD dwErrorCode, ...)
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode, ...)
{
int iRet = 0;
LPTSTR lpMsgBuf = NULL;
LPWSTR lpMsgBuf = NULL;
DWORD Status = 0;
va_list args = NULL;
va_start(args, dwErrorCode);
Status = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpMsgBuf,
0,
&args);
Status = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&lpMsgBuf,
0,
&args);
va_end(args);
iRet = MessageBox(hWnd, (Status && lpMsgBuf ? lpMsgBuf : TEXT("Error displaying error message.\n")), lpTitle, MB_OK | MB_ICONERROR);
iRet = MessageBoxW(hWnd, (Status && lpMsgBuf ? lpMsgBuf : L"Error displaying error message.\n"), lpTitle, MB_OK | MB_ICONERROR);
if (lpMsgBuf) LocalFree(lpMsgBuf);
/* Return the MessageBox information */
/* Return the MessageBoxW information */
return iRet;
}
int InfoMessageBox(HWND hWnd, UINT uType, LPCTSTR lpTitle, LPCTSTR lpMessage, ...)
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage, ...)
{
int iRet = 0;
LPTSTR lpMsgBuf = NULL;
LPWSTR lpMsgBuf = NULL;
DWORD Status = 0;
va_list args = NULL;
va_start(args, lpMessage);
Status = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
lpMessage,
0,
0,
(LPTSTR)&lpMsgBuf,
0,
&args);
Status = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
lpMessage,
0,
0,
(LPWSTR)&lpMsgBuf,
0,
&args);
va_end(args);
iRet = MessageBox(hWnd, (Status && lpMsgBuf ? lpMsgBuf : TEXT("Error displaying error message.\n")), lpTitle, uType);
iRet = MessageBoxW(hWnd, (Status && lpMsgBuf ? lpMsgBuf : L"Error displaying error message.\n"), lpTitle, uType);
if (lpMsgBuf) LocalFree(lpMsgBuf);
/* Return the MessageBox information */
/* Return the MessageBoxW information */
return iRet;
}

View file

@ -20,69 +20,69 @@
#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 WCHAR s_szName[MAX_PATH];
static DWORD s_cbName;
static const TCHAR s_empty[] = {0};
static const TCHAR s_backslash[] = {'\\', 0};
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;
}
@ -91,19 +91,19 @@ static BOOL CompareName(LPCTSTR pszName1, LPCTSTR pszName2)
static BOOL
CompareData(
DWORD dwType,
LPCTSTR psz1,
LPCTSTR psz2)
LPCWSTR psz1,
LPCWSTR psz2)
{
INT i, cch1 = lstrlen(psz1), cch2 = lstrlen(psz2);
INT i, cch1 = wcslen(psz1), cch2 = wcslen(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,
return 2 == CompareStringW(LOCALE_SYSTEM_DEFAULT, 0,
psz1, cch1, psz2, cch2);
else
return 2 == CompareString(LOCALE_SYSTEM_DEFAULT,
return 2 == CompareStringW(LOCALE_SYSTEM_DEFAULT,
NORM_IGNORECASE, psz1, cch1, psz2, cch2);
}
@ -111,13 +111,13 @@ CompareData(
{
if (s_dwFlags & RSF_MATCHCASE)
{
if (2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0,
if (2 == CompareStringW(LOCALE_SYSTEM_DEFAULT, 0,
psz1 + i, cch2, psz2, cch2))
return TRUE;
}
else
{
if (2 == CompareString(LOCALE_SYSTEM_DEFAULT,
if (2 == CompareStringW(LOCALE_SYSTEM_DEFAULT,
NORM_IGNORECASE, psz1 + i, cch2, psz2, cch2))
return TRUE;
}
@ -128,55 +128,55 @@ CompareData(
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;
LPWSTR *ppszNames = NULL;
LPBYTE pb = NULL;
if (DoEvents())
return FALSE;
lstrcpy(szSubKey, pszSubKey);
wcscpy(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));
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_cbName = MAX_PATH * sizeof(WCHAR);
lResult = RegEnumValueW(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
NULL, &cb);
if (lResult == ERROR_NO_MORE_ITEMS)
{
@ -185,20 +185,20 @@ BOOL RegFindRecurse(
}
if (lResult != ERROR_SUCCESS)
goto err;
if (s_cbName >= MAX_PATH * sizeof(TCHAR))
if (s_cbName >= MAX_PATH * sizeof(WCHAR))
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 (DoEvents())
goto err;
if (!fPast && lstrcmpi(ppszNames[i], pszValueName) == 0)
if (!fPast && wcsicmp(ppszNames[i], pszValueName) == 0)
{
fPast = TRUE;
continue;
@ -209,34 +209,34 @@ BOOL RegFindRecurse(
if ((s_dwFlags & RSF_LOOKATVALUES) &&
CompareName(ppszNames[i], s_szFindWhat))
{
*ppszFoundSubKey = _tcsdup(szSubKey);
*ppszFoundSubKey = _wcsdup(szSubKey);
if (ppszNames[i][0] == 0)
*ppszFoundValueName = NULL;
else
*ppszFoundValueName = _tcsdup(ppszNames[i]);
*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))
CompareData(type, (LPWSTR) pb, s_szFindWhat))
{
*ppszFoundSubKey = _tcsdup(szSubKey);
*ppszFoundSubKey = _wcsdup(szSubKey);
if (ppszNames[i][0] == 0)
*ppszFoundValueName = NULL;
else
*ppszFoundValueName = _tcsdup(ppszNames[i]);
*ppszFoundValueName = _wcsdup(ppszNames[i]);
goto success;
}
free(pb);
@ -251,22 +251,22 @@ BOOL RegFindRecurse(
}
ppszNames = NULL;
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 = RegEnumKeyEx(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
s_cbName = MAX_PATH * sizeof(WCHAR);
lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
NULL, NULL);
if (lResult == ERROR_NO_MORE_ITEMS)
{
@ -275,13 +275,13 @@ BOOL RegFindRecurse(
}
if (lResult != ERROR_SUCCESS)
goto err;
if (s_cbName >= MAX_PATH * sizeof(TCHAR))
if (s_cbName >= MAX_PATH * sizeof(WCHAR))
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++)
{
@ -292,18 +292,18 @@ BOOL RegFindRecurse(
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;
}
@ -311,19 +311,19 @@ BOOL RegFindRecurse(
if (RegFindRecurse(hSubKey, ppszNames[i], NULL, ppszFoundSubKey,
ppszFoundValueName))
{
LPTSTR psz = *ppszFoundSubKey;
LPWSTR psz = *ppszFoundSubKey;
*ppszFoundSubKey = malloc(
(lstrlen(szSubKey) + lstrlen(psz) + 2) * sizeof(TCHAR));
(wcslen(szSubKey) + wcslen(psz) + 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, psz);
wcscat(*ppszFoundSubKey, psz);
free(psz);
goto success;
}
@ -353,67 +353,67 @@ 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;
WCHAR szKeyName[MAX_PATH];
WCHAR szSubKey[MAX_PATH];
LPWSTR pch;
BOOL fPast;
LPTSTR *ppszNames = NULL;
LPWSTR *ppszNames = NULL;
hBaseKey = *phKey;
if (RegFindRecurse(hBaseKey, pszSubKey, pszValueName, ppszFoundSubKey,
ppszFoundValueName))
return TRUE;
if (lstrlen(pszSubKey) >= MAX_PATH)
if (wcslen(pszSubKey) >= MAX_PATH)
return FALSE;
lstrcpy(szSubKey, pszSubKey);
wcscpy(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);
wcsncpy(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);
s_cbName = MAX_PATH * sizeof(WCHAR);
lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cbName,
NULL, NULL, NULL, NULL);
if (lResult == ERROR_NO_MORE_ITEMS)
@ -423,10 +423,10 @@ BOOL RegFindWalk(
}
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++)
@ -434,7 +434,7 @@ BOOL RegFindWalk(
if (DoEvents())
goto err;
if (!fPast && lstrcmpi(ppszNames[i], szKeyName) == 0)
if (!fPast && wcsicmp(ppszNames[i], szKeyName) == 0)
{
fPast = TRUE;
continue;
@ -446,18 +446,18 @@ BOOL RegFindWalk(
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;
}
@ -465,20 +465,20 @@ BOOL RegFindWalk(
if (RegFindRecurse(hSubKey, ppszNames[i], NULL,
ppszFoundSubKey, ppszFoundValueName))
{
LPTSTR psz = *ppszFoundSubKey;
LPWSTR psz = *ppszFoundSubKey;
*ppszFoundSubKey = malloc(
(lstrlen(szSubKey) + lstrlen(psz) + 2) *
sizeof(TCHAR));
(wcslen(szSubKey) + wcslen(psz) + 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, psz);
wcscat(*ppszFoundSubKey, psz);
free(psz);
goto success;
}
@ -557,11 +557,11 @@ static DWORD GetFindFlags(void)
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);
@ -569,7 +569,7 @@ static DWORD GetFindFlags(void)
/* 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);
@ -586,13 +586,13 @@ static void SetFindFlags(DWORD dwFlags)
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, 0, 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);
}
@ -629,13 +629,13 @@ static INT_PTR CALLBACK AbortFindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam,
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;
@ -651,8 +651,8 @@ BOOL FindNext(HWND hWnd)
}
/* 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);
@ -699,7 +699,7 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
HWND hControl;
LONG lStyle;
DWORD dwFlags;
static TCHAR s_szSavedFindValue[256];
static WCHAR s_szSavedFindValue[256];
switch(uMsg)
{
@ -708,32 +708,32 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
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;
@ -751,30 +751,30 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
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, COUNT_OF(s_szFindWhat));
GetWindowTextW(hControl, s_szFindWhat, COUNT_OF(s_szFindWhat));
EndDialog(hDlg, 1);
break;
@ -788,7 +788,7 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
switch(LOWORD(wParam))
{
case IDC_FINDWHAT:
GetWindowText((HWND) lParam, s_szSavedFindValue, COUNT_OF(s_szSavedFindValue));
GetWindowTextW((HWND) lParam, s_szSavedFindValue, COUNT_OF(s_szSavedFindValue));
hControl = GetDlgItem(hDlg, IDOK);
if (hControl)
{
@ -810,16 +810,16 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
void FindDialog(HWND hWnd)
{
if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FIND),
if (DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_FIND),
hWnd, FindDialogProc, 0) != 0)
{
if (!FindNext(hWnd))
{
TCHAR msg[128], caption[128];
WCHAR msg[128], caption[128];
LoadString(hInst, IDS_FINISHEDFIND, msg, COUNT_OF(msg));
LoadString(hInst, IDS_APP_TITLE, caption, COUNT_OF(caption));
MessageBox(0, msg, caption, MB_ICONINFORMATION);
LoadStringW(hInst, IDS_FINISHEDFIND, msg, COUNT_OF(msg));
LoadStringW(hInst, IDS_APP_TITLE, caption, COUNT_OF(caption));
MessageBoxW(0, msg, caption, MB_ICONINFORMATION);
}
}
}

View file

@ -26,7 +26,7 @@
#define FAVORITES_MENU_POSITION 3
static TCHAR s_szFavoritesRegKey[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites");
static WCHAR s_szFavoritesRegKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites";
static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
@ -39,7 +39,7 @@ static void resize_frame_rect(HWND hWnd, PRECT prect)
RECT rt;
/*
if (IsWindowVisible(hToolBar)) {
SendMessage(hToolBar, WM_SIZE, 0, 0);
SendMessageW(hToolBar, WM_SIZE, 0, 0);
GetClientRect(hToolBar, &rt);
prect->top = rt.bottom+3;
prect->bottom -= rt.bottom+3;
@ -69,7 +69,7 @@ static void OnInitMenu(HWND hWnd)
LONG lResult;
HKEY hKey = NULL;
DWORD dwIndex, cbValueName, cbValueData, dwType;
TCHAR szValueName[256];
WCHAR szValueName[256];
BYTE abValueData[256];
static int s_nFavoriteMenuSubPos = -1;
HMENU hMenu;
@ -89,7 +89,7 @@ static void OnInitMenu(HWND hWnd)
;
}
lResult = RegOpenKey(HKEY_CURRENT_USER, s_szFavoritesRegKey, &hKey);
lResult = RegOpenKeyW(HKEY_CURRENT_USER, s_szFavoritesRegKey, &hKey);
if (lResult != ERROR_SUCCESS)
goto done;
@ -98,7 +98,7 @@ static void OnInitMenu(HWND hWnd)
{
cbValueName = COUNT_OF(szValueName);
cbValueData = sizeof(abValueData);
lResult = RegEnumValue(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData);
lResult = RegEnumValueW(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData);
if ((lResult == ERROR_SUCCESS) && (dwType == REG_SZ))
{
if (!bDisplayedAny)
@ -124,9 +124,9 @@ static void OnEnterMenuLoop(HWND hWnd)
/* Update the status bar pane sizes */
nParts = -1;
SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
bInMenuLoop = TRUE;
SendMessage(hStatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)_T(""));
SendMessageW(hStatusBar, SB_SETTEXTW, (WPARAM)0, (LPARAM)L"");
}
static void OnExitMenuLoop(HWND hWnd)
@ -139,9 +139,9 @@ static void OnExitMenuLoop(HWND hWnd)
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
{
TCHAR str[100];
WCHAR str[100];
_tcscpy(str, _T(""));
wcscpy(str, L"");
if (nFlags & MF_POPUP)
{
if (hSysMenu != GetMenu(hWnd))
@ -149,16 +149,16 @@ static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
if (nItemID == 2) nItemID = 5;
}
}
if (LoadString(hInst, nItemID, str, 100))
if (LoadStringW(hInst, nItemID, str, 100))
{
/* load appropriate string*/
LPTSTR lpsz = str;
LPWSTR lpsz = str;
/* first newline terminates actual string*/
lpsz = _tcschr(lpsz, _T('\n'));
lpsz = wcschr(lpsz, L'\n');
if (lpsz != NULL)
*lpsz = '\0';
*lpsz = L'\0';
}
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)str);
SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)str);
}
void SetupStatusBar(HWND hWnd, BOOL bResize)
@ -169,8 +169,8 @@ void SetupStatusBar(HWND hWnd, BOOL bResize)
nParts = rc.right;
/* nParts = -1;*/
if (bResize)
SendMessage(hStatusBar, WM_SIZE, 0, 0);
SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
SendMessageW(hStatusBar, WM_SIZE, 0, 0);
SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
}
void UpdateStatusBar(void)
@ -178,7 +178,7 @@ void UpdateStatusBar(void)
NMHDR nmhdr;
ZeroMemory(&nmhdr, sizeof(NMHDR));
nmhdr.code = TVN_SELCHANGED;
SendMessage(g_pChildWnd->hWnd, WM_NOTIFY, (WPARAM)TREE_WINDOW, (LPARAM)&nmhdr);
SendMessageW(g_pChildWnd->hWnd, WM_NOTIFY, (WPARAM)TREE_WINDOW, (LPARAM)&nmhdr);
}
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
@ -197,44 +197,44 @@ static BOOL CheckCommDlgError(HWND hWnd)
UNREFERENCED_PARAMETER(hWnd);
switch (dwErrorCode)
{
case CDERR_DIALOGFAILURE:
break;
case CDERR_FINDRESFAILURE:
break;
case CDERR_NOHINSTANCE:
break;
case CDERR_INITIALIZATION:
break;
case CDERR_NOHOOK:
break;
case CDERR_LOCKRESFAILURE:
break;
case CDERR_NOTEMPLATE:
break;
case CDERR_LOADRESFAILURE:
break;
case CDERR_STRUCTSIZE:
break;
case CDERR_LOADSTRFAILURE:
break;
case FNERR_BUFFERTOOSMALL:
break;
case CDERR_MEMALLOCFAILURE:
break;
case FNERR_INVALIDFILENAME:
break;
case CDERR_MEMLOCKFAILURE:
break;
case FNERR_SUBCLASSFAILURE:
break;
default:
break;
case CDERR_DIALOGFAILURE:
break;
case CDERR_FINDRESFAILURE:
break;
case CDERR_NOHINSTANCE:
break;
case CDERR_INITIALIZATION:
break;
case CDERR_NOHOOK:
break;
case CDERR_LOCKRESFAILURE:
break;
case CDERR_NOTEMPLATE:
break;
case CDERR_LOADRESFAILURE:
break;
case CDERR_STRUCTSIZE:
break;
case CDERR_LOADSTRFAILURE:
break;
case FNERR_BUFFERTOOSMALL:
break;
case CDERR_MEMALLOCFAILURE:
break;
case FNERR_INVALIDFILENAME:
break;
case CDERR_MEMLOCKFAILURE:
break;
case FNERR_SUBCLASSFAILURE:
break;
default:
break;
}
return TRUE;
}
TCHAR FileNameBuffer[_MAX_PATH];
TCHAR FileTitleBuffer[_MAX_PATH];
WCHAR FileNameBuffer[_MAX_PATH];
WCHAR FileTitleBuffer[_MAX_PATH];
typedef struct
{
@ -243,25 +243,25 @@ typedef struct
} FILTERPAIR, *PFILTERPAIR;
void
BuildFilterStrings(TCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
{
int i, c;
c = 0;
for(i = 0; i < PairCount; i++)
{
c += LoadString(hInst, Pairs[i].DisplayID, &Filter[c], 255 * sizeof(TCHAR));
Filter[++c] = '\0';
c += LoadString(hInst, Pairs[i].FilterID, &Filter[c], 255 * sizeof(TCHAR));
Filter[++c] = '\0';
c += LoadStringW(hInst, Pairs[i].DisplayID, &Filter[c], 255 * sizeof(WCHAR));
Filter[++c] = L'\0';
c += LoadStringW(hInst, Pairs[i].FilterID, &Filter[c], 255 * sizeof(WCHAR));
Filter[++c] = L'\0';
}
Filter[++c] = '\0';
Filter[++c] = L'\0';
}
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
{
FILTERPAIR FilterPairs[4];
static TCHAR Filter[1024];
static WCHAR Filter[1024];
memset(pofn, 0, sizeof(OPENFILENAME));
pofn->lStructSize = sizeof(OPENFILENAME);
@ -285,24 +285,24 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
pofn->lpstrFileTitle = FileTitleBuffer;
pofn->nMaxFileTitle = _MAX_PATH;
pofn->Flags = OFN_HIDEREADONLY;
pofn->lpstrDefExt = TEXT("reg");
pofn->lpstrDefExt = L"reg";
return TRUE;
}
static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static LPTSTR sKey = NULL;
static LPWSTR sKey = NULL;
static INT sLength = 0;
switch(uMsg)
{
case WM_INITDIALOG:
sKey = (LPTSTR)lParam;
sKey = (LPWSTR)lParam;
sLength = 128; /* FIXME: Ugly hack! */
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
if(GetDlgItemText(hWndDlg, IDC_EDIT_KEY, sKey, sLength))
if(GetDlgItemTextW(hWndDlg, IDC_EDIT_KEY, sKey, sLength))
return EndDialog(hWndDlg, -1);
else
return EndDialog(hWndDlg, 0);
@ -314,7 +314,7 @@ static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPAR
return FALSE;
}
static BOOL EnablePrivilege(LPCTSTR lpszPrivilegeName, LPCTSTR lpszSystemName, BOOL bEnablePrivilege)
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
{
BOOL bRet = FALSE;
HANDLE hToken = NULL;
@ -328,9 +328,9 @@ static BOOL EnablePrivilege(LPCTSTR lpszPrivilegeName, LPCTSTR lpszSystemName, B
tp.PrivilegeCount = 1;
tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
if (LookupPrivilegeValue(lpszSystemName,
lpszPrivilegeName,
&tp.Privileges[0].Luid))
if (LookupPrivilegeValueW(lpszSystemName,
lpszPrivilegeName,
&tp.Privileges[0].Luid))
{
bRet = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
@ -347,11 +347,11 @@ static BOOL EnablePrivilege(LPCTSTR lpszPrivilegeName, LPCTSTR lpszSystemName, B
static BOOL LoadHive(HWND hWnd)
{
OPENFILENAME ofn;
TCHAR Caption[128];
LPCTSTR pszKeyPath;
TCHAR xPath[128];
WCHAR Caption[128];
LPCWSTR pszKeyPath;
WCHAR xPath[128];
HKEY hRootKey;
TCHAR Filter[1024];
WCHAR Filter[1024];
FILTERPAIR filter;
/* get the item key to load the hive in */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
@ -363,20 +363,20 @@ static BOOL LoadHive(HWND hWnd)
BuildFilterStrings(Filter, &filter, sizeof(filter));
ofn.lpstrFilter = Filter;
/* load and set the caption and flags for dialog */
LoadString(hInst, IDS_LOAD_HIVE, Caption, COUNT_OF(Caption));
LoadStringW(hInst, IDS_LOAD_HIVE, Caption, COUNT_OF(Caption));
ofn.lpstrTitle = Caption;
ofn.Flags |= OFN_ENABLESIZING;
/* ofn.lCustData = ;*/
/* now load the hive */
if (GetOpenFileName(&ofn))
{
if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_LOADHIVE), hWnd, &LoadHive_KeyNameInHookProc, (LPARAM)xPath))
if(DialogBoxParamW(hInst, MAKEINTRESOURCEW(IDD_LOADHIVE), hWnd, &LoadHive_KeyNameInHookProc, (LPARAM)xPath))
{
LONG regLoadResult;
/* Enable the 'restore' privilege, load the hive, disable the privilege */
EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
regLoadResult = RegLoadKey(hRootKey, xPath, ofn.lpstrFile);
regLoadResult = RegLoadKeyW(hRootKey, xPath, ofn.lpstrFile);
EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);
if(regLoadResult == ERROR_SUCCESS)
@ -402,19 +402,19 @@ static BOOL LoadHive(HWND hWnd)
static BOOL UnloadHive(HWND hWnd)
{
TCHAR Caption[128];
LPCTSTR pszKeyPath;
WCHAR Caption[128];
LPCWSTR pszKeyPath;
HKEY hRootKey;
LONG regUnloadResult;
/* get the item key to unload */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
/* load and set the caption and flags for dialog */
LoadString(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));
LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));
/* Enable the 'restore' privilege, unload the hive, disable the privilege */
EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
regUnloadResult = RegUnLoadKey(hRootKey, pszKeyPath);
regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath);
EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);
if(regUnloadResult == ERROR_SUCCESS)
@ -436,15 +436,15 @@ static BOOL ImportRegistryFile(HWND hWnd)
{
BOOL bRet = FALSE;
OPENFILENAME ofn;
TCHAR Caption[128], szTitle[256], szText[256];
WCHAR Caption[128], szTitle[256], szText[256];
HKEY hKeyRoot;
LPCTSTR pszKeyPath;
LPCWSTR pszKeyPath;
/* Figure out in which key path we are importing */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
InitOpenFileName(hWnd, &ofn);
LoadString(hInst, IDS_IMPORT_REG_FILE, Caption, COUNT_OF(Caption));
LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, COUNT_OF(Caption));
ofn.lpstrTitle = Caption;
ofn.Flags |= OFN_ENABLESIZING;
/* ofn.lCustData = ;*/
@ -452,7 +452,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
{
/* Look at the extension of the file to determine its type */
if (ofn.nFileExtension >= 1 &&
_tcsicmp(ofn.lpstrFile + ofn.nFileExtension, TEXT("reg")) == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"reg") == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
{
/* Open the file */
FILE *fp = _wfopen(ofn.lpstrFile, L"r");
@ -461,16 +461,16 @@ static BOOL ImportRegistryFile(HWND hWnd)
if (fp == NULL || !import_registry_file(fp))
{
LPSTR p = GetMultiByteString(ofn.lpstrFile);
fprintf(stderr, "Can't open file \"%s\"\n", p);
fwprintf(stderr, L"Can't open file \"%s\"\n", p);
HeapFree(GetProcessHeap(), 0, p);
bRet = FALSE;
}
else
{
/* Show successful import */
LoadString(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
LoadString(hInst, IDS_IMPORT_OK, szText, COUNT_OF(szText));
MessageBox(NULL, szText, szTitle, MB_OK);
LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
LoadStringW(hInst, IDS_IMPORT_OK, szText, COUNT_OF(szText));
MessageBoxW(NULL, szText, szTitle, MB_OK);
bRet = TRUE;
}
@ -479,17 +479,17 @@ static BOOL ImportRegistryFile(HWND hWnd)
}
else /* Registry Hive Files */
{
LoadString(hInst, IDS_QUERY_IMPORT_HIVE_CAPTION, szTitle, COUNT_OF(szTitle));
LoadString(hInst, IDS_QUERY_IMPORT_HIVE_MSG, szText, COUNT_OF(szText));
LoadStringW(hInst, IDS_QUERY_IMPORT_HIVE_CAPTION, szTitle, COUNT_OF(szTitle));
LoadStringW(hInst, IDS_QUERY_IMPORT_HIVE_MSG, szText, COUNT_OF(szText));
/* Display a confirmation message */
if (MessageBox(g_pChildWnd->hWnd, szText, szTitle, MB_ICONWARNING | MB_YESNO) == IDYES)
if (MessageBoxW(g_pChildWnd->hWnd, szText, szTitle, MB_ICONWARNING | MB_YESNO) == IDYES)
{
LONG lResult;
HKEY hSubKey;
/* Open the subkey */
lResult = RegOpenKeyEx(hKeyRoot, pszKeyPath, 0, KEY_WRITE, &hSubKey);
lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_WRITE, &hSubKey);
if (lResult == ERROR_SUCCESS)
{
/* Enable the 'restore' privilege, restore the hive then disable the privilege */
@ -530,7 +530,7 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W
HWND hwndExportBranchText;
UINT_PTR iResult = 0;
OPENFILENAME *pOfn;
LPTSTR pszSelectedKey;
LPWSTR pszSelectedKey;
OFNOTIFY *pOfnNotify;
UNREFERENCED_PARAMETER(wParam);
@ -539,37 +539,37 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W
{
case WM_INITDIALOG:
pOfn = (OPENFILENAME *) lParam;
pszSelectedKey = (LPTSTR) pOfn->lCustData;
pszSelectedKey = (LPWSTR) pOfn->lCustData;
hwndExportAll = GetDlgItem(hdlg, IDC_EXPORT_ALL);
if (hwndExportAll)
SendMessage(hwndExportAll, BM_SETCHECK, pszSelectedKey ? BST_UNCHECKED : BST_CHECKED, 0);
SendMessageW(hwndExportAll, BM_SETCHECK, pszSelectedKey ? BST_UNCHECKED : BST_CHECKED, 0);
hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
if (hwndExportBranch)
SendMessage(hwndExportBranch, BM_SETCHECK, pszSelectedKey ? BST_CHECKED : BST_UNCHECKED, 0);
SendMessageW(hwndExportBranch, BM_SETCHECK, pszSelectedKey ? BST_CHECKED : BST_UNCHECKED, 0);
hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
if (hwndExportBranchText)
SetWindowText(hwndExportBranchText, pszSelectedKey);
SetWindowTextW(hwndExportBranchText, pszSelectedKey);
break;
case WM_NOTIFY:
if (((NMHDR *) lParam)->code == CDN_FILEOK)
{
pOfnNotify = (OFNOTIFY *) lParam;
pszSelectedKey = (LPTSTR) pOfnNotify->lpOFN->lCustData;
pszSelectedKey = (LPWSTR) pOfnNotify->lpOFN->lCustData;
hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
if (hwndExportBranch && hwndExportBranchText
&& (SendMessage(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
&& (SendMessageW(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
{
GetWindowText(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
GetWindowTextW(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
}
else
{
pszSelectedKey[0] = '\0';
pszSelectedKey[0] = L'\0';
}
}
break;
@ -581,17 +581,17 @@ BOOL ExportRegistryFile(HWND hWnd)
{
BOOL bRet = FALSE;
OPENFILENAME ofn;
TCHAR ExportKeyPath[_MAX_PATH];
TCHAR Caption[128];
WCHAR ExportKeyPath[_MAX_PATH];
WCHAR Caption[128];
HKEY hKeyRoot;
LPCTSTR pszKeyPath;
LPCWSTR pszKeyPath;
/* Figure out which key path we are exporting */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
GetKeyName(ExportKeyPath, COUNT_OF(ExportKeyPath), hKeyRoot, pszKeyPath);
InitOpenFileName(hWnd, &ofn);
LoadString(hInst, IDS_EXPORT_REG_FILE, Caption, COUNT_OF(Caption));
LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, COUNT_OF(Caption));
ofn.lpstrTitle = Caption;
/* Only set the path if a key (not the root node) is selected */
@ -601,7 +601,7 @@ BOOL ExportRegistryFile(HWND hWnd)
}
ofn.Flags = OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_OVERWRITEPROMPT;
ofn.lpfnHook = ExportRegistryFile_OFNHookProc;
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXPORTRANGE);
ofn.lpTemplateName = MAKEINTRESOURCEW(IDD_EXPORTRANGE);
if (GetSaveFileName(&ofn))
{
switch (ofn.nFilterIndex)
@ -612,22 +612,22 @@ BOOL ExportRegistryFile(HWND hWnd)
HKEY hSubKey;
/* Open the subkey */
lResult = RegOpenKeyEx(hKeyRoot, pszKeyPath, 0, KEY_READ, &hSubKey);
lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_READ, &hSubKey);
if (lResult == ERROR_SUCCESS)
{
/* Enable the 'backup' privilege, save the hive then disable the privilege */
EnablePrivilege(SE_BACKUP_NAME, NULL, TRUE);
lResult = RegSaveKey(hSubKey, ofn.lpstrFile, NULL);
lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
if (lResult == ERROR_ALREADY_EXISTS)
{
/*
* We are here, that means that we already said "yes" to the confirmation dialog.
* So we absolutely want to replace the hive file.
*/
if (DeleteFile(ofn.lpstrFile))
if (DeleteFileW(ofn.lpstrFile))
{
/* Try again */
lResult = RegSaveKey(hSubKey, ofn.lpstrFile, NULL);
lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
}
}
EnablePrivilege(SE_BACKUP_NAME, NULL, FALSE);
@ -635,12 +635,12 @@ BOOL ExportRegistryFile(HWND hWnd)
if (lResult != ERROR_SUCCESS)
{
/*
* If we are here, it's because RegSaveKey has failed for any reason.
* If we are here, it's because RegSaveKeyW has failed for any reason.
* The problem is that even if it has failed, it has created or
* replaced the exported hive file with a new empty file. We don't
* want to keep this file, so we delete it.
*/
DeleteFile(ofn.lpstrFile);
DeleteFileW(ofn.lpstrFile);
}
/* Close the subkey */
@ -665,7 +665,7 @@ BOOL ExportRegistryFile(HWND hWnd)
: REG_FORMAT_5)))
{
LPSTR p = GetMultiByteString(ofn.lpstrFile);
fprintf(stderr, "Can't open file \"%s\"\n", p);
fwprintf(stderr, L"Can't open file \"%s\"\n", p);
HeapFree(GetProcessHeap(), 0, p);
bRet = FALSE;
}
@ -686,7 +686,7 @@ BOOL ExportRegistryFile(HWND hWnd)
return bRet;
}
BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
BOOL PrintRegistryHive(HWND hWnd, LPWSTR path)
{
#if 1
PRINTDLG pd;
@ -758,18 +758,18 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
return TRUE;
}
static void ChooseFavorite(LPCTSTR pszFavorite)
static void ChooseFavorite(LPCWSTR pszFavorite)
{
HKEY hKey = NULL;
TCHAR szFavoritePath[512];
WCHAR szFavoritePath[512];
DWORD cbData, dwType;
if (RegOpenKeyEx(HKEY_CURRENT_USER, s_szFavoritesRegKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
if (RegOpenKeyExW(HKEY_CURRENT_USER, s_szFavoritesRegKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
goto done;
cbData = (sizeof(szFavoritePath) / sizeof(szFavoritePath[0])) - 1;
memset(szFavoritePath, 0, sizeof(szFavoritePath));
if (RegQueryValueEx(hKey, pszFavorite, NULL, &dwType, (LPBYTE) szFavoritePath, &cbData) != ERROR_SUCCESS)
if (RegQueryValueExW(hKey, pszFavorite, NULL, &dwType, (LPBYTE) szFavoritePath, &cbData) != ERROR_SUCCESS)
goto done;
if (dwType == REG_SZ)
@ -780,13 +780,13 @@ done:
RegCloseKey(hKey);
}
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCTSTR keyName)
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
{
BOOL bClipboardOpened = FALSE;
BOOL bSuccess = FALSE;
TCHAR szBuffer[512];
WCHAR szBuffer[512];
HGLOBAL hGlobal;
LPTSTR s;
LPWSTR s;
if (!OpenClipboard(hWnd))
goto done;
@ -798,19 +798,15 @@ BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCTSTR keyName)
if (!GetKeyName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName))
goto done;
hGlobal = GlobalAlloc(GMEM_MOVEABLE, (lstrlen(szBuffer) + 1) * sizeof(TCHAR));
hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
if (!hGlobal)
goto done;
s = GlobalLock(hGlobal);
_tcscpy(s, szBuffer);
wcscpy(s, szBuffer);
GlobalUnlock(hGlobal);
#ifdef UNICODE
SetClipboardData(CF_UNICODETEXT, hGlobal);
#else
SetClipboardData(CF_TEXT, hGlobal);
#endif
bSuccess = TRUE;
done:
@ -819,10 +815,10 @@ done:
return bSuccess;
}
static BOOL CreateNewValue(HKEY hRootKey, LPCTSTR pszKeyPath, DWORD dwType)
static BOOL CreateNewValue(HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType)
{
TCHAR szNewValueFormat[128];
TCHAR szNewValue[128];
WCHAR szNewValueFormat[128];
WCHAR szNewValue[128];
int iIndex = 1;
BYTE data[128];
DWORD dwExistingType, cbData;
@ -830,41 +826,41 @@ static BOOL CreateNewValue(HKEY hRootKey, LPCTSTR pszKeyPath, DWORD dwType)
HKEY hKey;
LVFINDINFO lvfi;
if (RegOpenKeyEx(hRootKey, pszKeyPath, 0, KEY_QUERY_VALUE | KEY_SET_VALUE,
&hKey) != ERROR_SUCCESS)
if (RegOpenKeyExW(hRootKey, pszKeyPath, 0, KEY_QUERY_VALUE | KEY_SET_VALUE,
&hKey) != ERROR_SUCCESS)
return FALSE;
LoadString(hInst, IDS_NEW_VALUE, szNewValueFormat, COUNT_OF(szNewValueFormat));
LoadStringW(hInst, IDS_NEW_VALUE, szNewValueFormat, COUNT_OF(szNewValueFormat));
do
{
wsprintf(szNewValue, szNewValueFormat, iIndex++);
cbData = sizeof(data);
lResult = RegQueryValueEx(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
lResult = RegQueryValueExW(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
}
while(lResult == ERROR_SUCCESS);
switch(dwType)
{
case REG_DWORD:
cbData = sizeof(DWORD);
break;
case REG_SZ:
case REG_EXPAND_SZ:
cbData = sizeof(TCHAR);
break;
case REG_MULTI_SZ:
cbData = sizeof(TCHAR) * 2;
break;
case REG_QWORD:
cbData = sizeof(DWORD) * 2;
break;
default:
cbData = 0;
break;
case REG_DWORD:
cbData = sizeof(DWORD);
break;
case REG_SZ:
case REG_EXPAND_SZ:
cbData = sizeof(WCHAR);
break;
case REG_MULTI_SZ:
cbData = sizeof(WCHAR) * 2;
break;
case REG_QWORD:
cbData = sizeof(DWORD) * 2;
break;
default:
cbData = 0;
break;
}
memset(data, 0, cbData);
lResult = RegSetValueEx(hKey, szNewValue, 0, dwType, data, cbData);
lResult = RegSetValueExW(hKey, szNewValue, 0, dwType, data, cbData);
RegCloseKey(hKey);
if (lResult != ERROR_SUCCESS)
{
@ -946,7 +942,7 @@ InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
static HRESULT
InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker,
IN HWND hwndParent OPTIONAL,
OUT LPTSTR lpBuffer,
OUT LPWSTR lpBuffer,
IN UINT uSize)
{
IDataObject *pdo = NULL;
@ -960,7 +956,7 @@ InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker,
STGMEDIUM stm;
FORMATETC fe;
fe.cfFormat = (CLIPFORMAT) RegisterClipboardFormat(CFSTR_DSOP_DS_SELECTION_LIST);
fe.cfFormat = (CLIPFORMAT) RegisterClipboardFormatW(CFSTR_DSOP_DS_SELECTION_LIST);
fe.ptd = NULL;
fe.dwAspect = DVASPECT_CONTENT;
fe.lindex = -1;
@ -981,20 +977,11 @@ InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker,
{
nlen = uSize - 1;
}
#if UNICODE
memcpy(lpBuffer,
SelectionList->aDsSelection[0].pwzName,
nlen * sizeof(WCHAR));
#else
WideCharToMultiByte(CP_ACP,
0,
SelectionList->aDsSelection[0].pwzName,
nlen,
lpBuffer,
uSize,
NULL,
NULL);
#endif
lpBuffer[nlen] = L'\0';
}
@ -1026,8 +1013,8 @@ FreeObjectPicker(IN IDsObjectPicker *pDsObjectPicker)
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HKEY hKeyRoot = 0, hKey = 0;
LPCTSTR keyPath;
LPCTSTR valueName;
LPCWSTR keyPath;
LPCWSTR valueName;
BOOL result = TRUE;
REGSAM regsam = KEY_READ;
LONG lRet;
@ -1053,7 +1040,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ID_REGISTRY_CONNECTNETWORKREGISTRY:
{
IDsObjectPicker *ObjectPicker;
TCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
HRESULT hRet;
hRet = CoInitialize(NULL);
@ -1082,7 +1069,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ID_REGISTRY_DISCONNECTNETWORKREGISTRY:
return TRUE;
case ID_REGISTRY_PRINT:
PrintRegistryHive(hWnd, _T(""));
PrintRegistryHive(hWnd, L"");
return TRUE;
case ID_REGISTRY_EXIT:
DestroyWindow(hWnd);
@ -1091,7 +1078,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
toggle_child(hWnd, LOWORD(wParam), hStatusBar);
return TRUE;
case ID_HELP_HELPTOPICS:
WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
WinHelpW(hWnd, getAppName(), HELP_FINDER, 0);
return TRUE;
case ID_HELP_ABOUT:
ShowAboutBox(hWnd);
@ -1107,8 +1094,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if(ClientToScreen(g_pChildWnd->hWnd, &pts))
{
SetCursorPos(pts.x, pts.y);
SetCursor(LoadCursor(0, IDC_SIZEWE));
SendMessage(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
SetCursor(LoadCursorW(0, IDC_SIZEWE));
SendMessageW(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
}
return TRUE;
}
@ -1124,7 +1111,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
valueName = GetValueName(g_pChildWnd->hListWnd, -1);
if (keyPath)
{
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, regsam, &hKey);
lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey);
if (lRet != ERROR_SUCCESS) hKey = 0;
}
@ -1165,10 +1152,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
if(nSelected >= 1)
{
TCHAR msg[128], caption[128];
LoadString(hInst, IDS_QUERY_DELETE_CONFIRM, caption, COUNT_OF(caption));
LoadString(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, COUNT_OF(msg));
if(MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
WCHAR msg[128], caption[128];
LoadStringW(hInst, IDS_QUERY_DELETE_CONFIRM, caption, COUNT_OF(caption));
LoadStringW(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, COUNT_OF(msg));
if(MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
{
int ni, errs;
@ -1177,7 +1164,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1)
{
valueName = GetValueName(g_pChildWnd->hListWnd, item);
if(RegDeleteValue(hKey, valueName) != ERROR_SUCCESS)
if(RegDeleteValueW(hKey, valueName) != ERROR_SUCCESS)
{
errs++;
}
@ -1187,9 +1174,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
if(errs > 0)
{
LoadString(hInst, IDS_ERR_DELVAL_CAPTION, caption, COUNT_OF(caption));
LoadString(hInst, IDS_ERR_DELETEVALUE, msg, COUNT_OF(msg));
MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
LoadStringW(hInst, IDS_ERR_DELVAL_CAPTION, caption, COUNT_OF(caption));
LoadStringW(hInst, IDS_ERR_DELETEVALUE, msg, COUNT_OF(msg));
MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
}
}
}
@ -1260,7 +1247,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HMENU hMenu;
MENUITEMINFO mii;
TCHAR szFavorite[512];
WCHAR szFavorite[512];
hMenu = GetSubMenu(GetMenu(hWnd), FAVORITES_MENU_POSITION);
@ -1304,13 +1291,13 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
switch (message)
{
case WM_CREATE:
CreateWindowEx(0, szChildClass, NULL, WS_CHILD | WS_VISIBLE,
CreateWindowExW(0, szChildClass, NULL, WS_CHILD | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, (HMENU)0, hInst, 0);
break;
case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam))
return DefWindowProc(hWnd, message, wParam, lParam);
return DefWindowProcW(hWnd, message, wParam, lParam);
break;
case WM_ACTIVATE:
if (LOWORD(hWnd))
@ -1335,15 +1322,15 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
break;
case WM_SYSCOLORCHANGE:
/* Forward WM_SYSCOLORCHANGE to common controls */
SendMessage(g_pChildWnd->hListWnd, WM_SYSCOLORCHANGE, 0, 0);
SendMessage(g_pChildWnd->hTreeWnd, WM_SYSCOLORCHANGE, 0, 0);
SendMessageW(g_pChildWnd->hListWnd, WM_SYSCOLORCHANGE, 0, 0);
SendMessageW(g_pChildWnd->hTreeWnd, WM_SYSCOLORCHANGE, 0, 0);
break;
case WM_DESTROY:
WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);
WinHelpW(hWnd, getAppName(), HELP_QUIT, 0);
SaveSettings();
PostQuitMessage(0);
default:
return DefWindowProc(hWnd, message, wParam, lParam);
return DefWindowProcW(hWnd, message, wParam, lParam);
}
return 0;
}

View file

@ -49,17 +49,17 @@ typedef struct
INT SelEnd;
} HEXEDIT_DATA, *PHEXEDIT_DATA;
static const TCHAR ClipboardFormatName[] = TEXT("RegEdit_HexData");
static const WCHAR ClipboardFormatName[] = L"RegEdit_HexData";
static UINT ClipboardFormatID = 0;
/* hit test codes */
#define HEHT_LEFTMARGIN (0x1)
#define HEHT_ADDRESS (0x2)
#define HEHT_ADDRESSSPACING (0x3)
#define HEHT_HEXDUMP (0x4)
#define HEHT_HEXDUMPSPACING (0x5)
#define HEHT_ASCIIDUMP (0x6)
#define HEHT_RIGHTMARGIN (0x7)
#define HEHT_LEFTMARGIN (0x1)
#define HEHT_ADDRESS (0x2)
#define HEHT_ADDRESSSPACING (0x3)
#define HEHT_HEXDUMP (0x4)
#define HEHT_HEXDUMPSPACING (0x5)
#define HEHT_ASCIIDUMP (0x6)
#define HEHT_RIGHTMARGIN (0x7)
INT_PTR CALLBACK HexEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@ -67,17 +67,17 @@ ATOM
WINAPI
RegisterHexEditorClass(HINSTANCE hInstance)
{
WNDCLASSEX WndClass;
WNDCLASSEXW WndClass;
ClipboardFormatID = RegisterClipboardFormat(ClipboardFormatName);
ClipboardFormatID = RegisterClipboardFormatW(ClipboardFormatName);
ZeroMemory(&WndClass, sizeof(WNDCLASSEX));
WndClass.cbSize = sizeof(WNDCLASSEX);
ZeroMemory(&WndClass, sizeof(WNDCLASSEXW));
WndClass.cbSize = sizeof(WNDCLASSEXW);
WndClass.style = CS_DBLCLKS;
WndClass.lpfnWndProc = (WNDPROC)HexEditWndProc;
WndClass.cbWndExtra = sizeof(PHEXEDIT_DATA);
WndClass.hInstance = hInstance;
WndClass.hCursor = LoadCursor(0, IDC_IBEAM);
WndClass.hCursor = LoadCursorW(NULL, IDC_IBEAM);
WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
WndClass.lpszClassName = HEX_EDIT_CLASS_NAME;
@ -88,7 +88,7 @@ BOOL
WINAPI
UnregisterHexEditorClass(HINSTANCE hInstance)
{
return UnregisterClass(HEX_EDIT_CLASS_NAME, hInstance);
return UnregisterClassW(HEX_EDIT_CLASS_NAME, hInstance);
}
/*** Helper functions *********************************************************/
@ -192,7 +192,7 @@ HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWO
INT i, isave, i0, i1, x;
PBYTE buf, current, end, line;
size_t bufsize;
TCHAR hex[3], addr[17];
WCHAR hex[3], addr[17];
RECT rct, rct2;
FillRect(hDC, rc, (HBRUSH)(COLOR_WINDOW + 1));
@ -222,8 +222,8 @@ HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWO
if(ScrollPos + First == 0)
{
/* draw address */
wsprintf(addr, TEXT("%04X"), 0);
TextOut(hDC, hed->LeftMargin, First * hed->LineHeight, addr, 4);
wsprintf(addr, L"%04X", 0);
TextOutW(hDC, hed->LeftMargin, First * hed->LineHeight, addr, 4);
}
}
@ -244,8 +244,8 @@ HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWO
dx = hed->LeftMargin;
/* draw address */
wsprintf(addr, TEXT("%04lX"), linestart);
TextOut(hDC, dx, dy, addr, 4);
wsprintf(addr, L"%04lX", linestart);
TextOutW(hDC, dx, dy, addr, 4);
dx += ((4 + hed->AddressSpacing) * hed->CharWidth);
dh = (3 * hed->CharWidth);
@ -264,7 +264,7 @@ HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWO
rct.left += dh;
rct.right += dh;
wsprintf(hex, TEXT("%02X"), *(current++));
wsprintf(hex, L"%02X", *(current++));
if (i0 <= i && i < i1)
{
rct2.left = dx;
@ -274,11 +274,11 @@ HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWO
InflateRect(&rct2, hed->CharWidth / 2, 0);
FillRect(hDC, &rct2, (HBRUSH)(COLOR_HIGHLIGHT + 1));
SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
ExtTextOut(hDC, dx, dy, 0, &rct, hex, 2, NULL);
ExtTextOutW(hDC, dx, dy, 0, &rct, hex, 2, NULL);
SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
}
else
ExtTextOut(hDC, dx, dy, ETO_OPAQUE, &rct, hex, 2, NULL);
ExtTextOutW(hDC, dx, dy, ETO_OPAQUE, &rct, hex, 2, NULL);
dx += dh;
i++;
}
@ -289,8 +289,8 @@ HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWO
i = isave;
for(x = 0; x < hed->ColumnsPerLine && current < end; x++)
{
wsprintf(hex, _T("%C"), *(current++));
hex[0] = ((hex[0] & _T('\x007f')) >= _T(' ') ? hex[0] : _T('.'));
wsprintf(hex, L"%C", *(current++));
hex[0] = ((hex[0] & L'\x007f') >= L' ' ? hex[0] : L'.');
if (i0 <= i && i < i1)
{
rct2.left = dx;
@ -299,11 +299,11 @@ HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWO
rct2.bottom = dy + hed->LineHeight;
FillRect(hDC, &rct2, (HBRUSH)(COLOR_HIGHLIGHT + 1));
SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
TextOut(hDC, dx, dy, hex, 1);
TextOutW(hDC, dx, dy, hex, 1);
SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
}
else
TextOut(hDC, dx, dy, hex, 1);
TextOutW(hDC, dx, dy, hex, 1);
dx += hed->CharWidth;
i++;
}
@ -1048,7 +1048,7 @@ HEXEDIT_WM_KEYDOWN(PHEXEDIT_DATA hed, INT VkCode)
{
case 'X':
if (GetAsyncKeyState(VK_SHIFT) >= 0 &&
GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd)
GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd)
HEXEDIT_Cut(hed);
else
return TRUE;
@ -1056,7 +1056,7 @@ HEXEDIT_WM_KEYDOWN(PHEXEDIT_DATA hed, INT VkCode)
case 'C':
if (GetAsyncKeyState(VK_SHIFT) >= 0 &&
GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd)
GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd)
HEXEDIT_Copy(hed);
else
return TRUE;
@ -1088,7 +1088,7 @@ HEXEDIT_WM_KEYDOWN(PHEXEDIT_DATA hed, INT VkCode)
case VK_DELETE:
if (GetAsyncKeyState(VK_SHIFT) < 0 && GetAsyncKeyState(VK_CONTROL) >= 0 &&
hed->SelStart != hed->SelEnd)
hed->SelStart != hed->SelEnd)
HEXEDIT_Copy(hed);
if (i0 != i1)
{
@ -1256,9 +1256,10 @@ HEXEDIT_WM_KEYDOWN(PHEXEDIT_DATA hed, INT VkCode)
}
static BOOL
HEXEDIT_WM_CHAR(PHEXEDIT_DATA hed, WCHAR ch)
HEXEDIT_WM_CHAR(PHEXEDIT_DATA hed, WCHAR wch)
{
size_t bufsize;
CHAR ch = (CHAR)wch; // keep the lowest octet.
PBYTE buf;
INT i0, i1;
@ -1410,7 +1411,7 @@ HEXEDIT_WM_CONTEXTMENU(PHEXEDIT_DATA hed, INT x, INT y)
SetForegroundWindow(hed->hWndSelf);
TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, x, y, 0, hed->hWndSelf, NULL);
PostMessage(hed->hWndSelf, WM_NULL, 0, 0);
PostMessageW(hed->hWndSelf, WM_NULL, 0, 0);
}
INT_PTR CALLBACK
@ -1548,6 +1549,6 @@ HexEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}

View file

@ -1,6 +1,6 @@
#pragma once
#define HEX_EDIT_CLASS_NAME _T("HexEdit32")
#define HEX_EDIT_CLASS_NAME L"HexEdit32"
ATOM WINAPI
RegisterHexEditorClass(HINSTANCE hInstance);
@ -8,30 +8,32 @@ BOOL WINAPI
UnregisterHexEditorClass(HINSTANCE hInstance);
/* styles */
#define HES_READONLY (0x800)
#define HES_LOWERCASE (0x10)
#define HES_UPPERCASE (0x8)
#define HES_AUTOVSCROLL (0x40)
#define HES_HIDEADDRESS (0x4)
#define HES_READONLY (0x800)
#define HES_LOWERCASE (0x10)
#define HES_UPPERCASE (0x8)
#define HES_AUTOVSCROLL (0x40)
#define HES_HIDEADDRESS (0x4)
/* messages */
#define HEM_BASE (WM_USER + 50)
#define HEM_LOADBUFFER (HEM_BASE + 1)
#define HEM_COPYBUFFER (HEM_BASE + 2)
#define HEM_SETMAXBUFFERSIZE (HEM_BASE + 3)
#define HEM_BASE (WM_USER + 50)
#define HEM_LOADBUFFER (HEM_BASE + 1)
#define HEM_COPYBUFFER (HEM_BASE + 2)
#define HEM_SETMAXBUFFERSIZE (HEM_BASE + 3)
/* macros */
#define HexEdit_LoadBuffer(hWnd, Buffer, Size) \
SendMessage((hWnd), HEM_LOADBUFFER, (WPARAM)(Buffer), (LPARAM)(Size))
SendMessageW((hWnd), HEM_LOADBUFFER, (WPARAM)(Buffer), (LPARAM)(Size))
#define HexEdit_ClearBuffer(hWnd) \
SendMessage((hWnd), HEM_LOADBUFFER, 0, 0)
SendMessageW((hWnd), HEM_LOADBUFFER, 0, 0)
#define HexEdit_CopyBuffer(hWnd, Buffer, nMax) \
SendMessage((hWnd), HEM_COPYBUFFER, (WPARAM)(Buffer), (LPARAM)(nMax))
SendMessageW((hWnd), HEM_COPYBUFFER, (WPARAM)(Buffer), (LPARAM)(nMax))
#define HexEdit_GetBufferSize(hWnd) \
SendMessage((hWnd), HEM_COPYBUFFER, 0, 0)
SendMessageW((hWnd), HEM_COPYBUFFER, 0, 0)
#define HexEdit_SetMaxBufferSize(hWnd, Size) \
SendMessage((hWnd), HEM_SETMAXBUFFERSIZE, 0, (LPARAM)(Size))
SendMessageW((hWnd), HEM_SETMAXBUFFERSIZE, 0, (LPARAM)(Size))
/* EOF */

View file

@ -23,7 +23,7 @@
#define CX_ICON 16
#define CY_ICON 16
#define NUM_ICONS 2
#define NUM_ICONS 2
int Image_String = 0;
int Image_Bin = 0;
@ -32,7 +32,7 @@ INT iListViewSelect = -1;
typedef struct tagLINE_INFO
{
DWORD dwValType;
LPTSTR name;
LPWSTR name;
void* val;
size_t val_len;
} LINE_INFO, *PLINE_INFO;
@ -48,7 +48,7 @@ static BOOL g_invertSort = FALSE;
static const int default_column_widths[MAX_LIST_COLUMNS] = { 200, 175, 400 };
static const int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT };
LPCTSTR GetValueName(HWND hwndLV, int iStartAt)
LPCWSTR GetValueName(HWND hwndLV, int iStartAt)
{
int item;
LVITEM LVItem;
@ -77,10 +77,10 @@ LPCTSTR GetValueName(HWND hwndLV, int iStartAt)
return lineinfo->name;
}
VOID SetValueName(HWND hwndLV, LPCTSTR pszValueName)
VOID SetValueName(HWND hwndLV, LPCWSTR pszValueName)
{
INT i, c;
LV_FINDINFO fi;
LVFINDINFOW fi;
c = ListView_GetItemCount(hwndLV);
for(i = 0; i < c; i++)
@ -110,7 +110,7 @@ BOOL IsDefaultValue(HWND hwndLV, int i)
if(ListView_GetItem(hwndLV, &Item))
{
lineinfo = (PLINE_INFO)Item.lParam;
return lineinfo && (!lineinfo->name || !_tcscmp(lineinfo->name, _T("")));
return lineinfo && (!lineinfo->name || !wcscmp(lineinfo->name, L""));
}
return FALSE;
}
@ -118,7 +118,7 @@ BOOL IsDefaultValue(HWND hwndLV, int i)
/*******************************************************************************
* Local module support methods
*/
static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValBuf, DWORD dwCount, int Position, BOOL ValExists)
static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType, void* ValBuf, DWORD dwCount, int Position, BOOL ValExists)
{
PLINE_INFO linfo;
LVITEM item;
@ -131,7 +131,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
{
memcpy(&linfo[1], ValBuf, dwCount);
}
linfo->name = _tcsdup(Name);
linfo->name = _wcsdup(Name);
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
item.iItem = (Position == -1 ? 0: Position);
@ -139,21 +139,21 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
item.state = 0;
item.stateMask = 0;
item.pszText = Name;
item.cchTextMax = (int) _tcslen(item.pszText);
item.cchTextMax = (int)wcslen(item.pszText);
if (item.cchTextMax == 0)
item.pszText = LPSTR_TEXTCALLBACK;
item.iImage = 0;
item.lParam = (LPARAM)linfo;
switch(dwValType)
{
case REG_SZ:
case REG_EXPAND_SZ:
case REG_MULTI_SZ:
item.iImage = Image_String;
break;
default:
item.iImage = Image_Bin;
break;
case REG_SZ:
case REG_EXPAND_SZ:
case REG_MULTI_SZ:
item.iImage = Image_String;
break;
default:
item.iImage = Image_Bin;
break;
}
/* item.lParam = (LPARAM)ValBuf; */
@ -174,49 +174,49 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
}
else if(!ValExists)
{
TCHAR buffer[255];
WCHAR buffer[255];
/* load (value not set) string */
LoadString(hInst, IDS_VALUE_NOT_SET, buffer, COUNT_OF(buffer));
LoadStringW(hInst, IDS_VALUE_NOT_SET, buffer, COUNT_OF(buffer));
ListView_SetItemText(hwndLV, index, 2, buffer);
}
break;
case REG_MULTI_SZ:
{
LPTSTR src, str;
LPWSTR src, str;
if(dwCount >= 2)
{
src = (LPTSTR)ValBuf;
str = HeapAlloc(GetProcessHeap(), 0, dwCount + sizeof(TCHAR));
src = (LPWSTR)ValBuf;
str = HeapAlloc(GetProcessHeap(), 0, dwCount + sizeof(WCHAR));
if(str != NULL)
{
*str = _T('\0');
*str = L'\0';
/* concatenate all srings */
while(*src != _T('\0'))
while(*src != L'\0')
{
_tcscat(str, src);
_tcscat(str, _T(" "));
src += _tcslen(src) + 1;
wcscat(str, src);
wcscat(str, L" ");
src += wcslen(src) + 1;
}
ListView_SetItemText(hwndLV, index, 2, str);
HeapFree(GetProcessHeap(), 0, str);
}
else
ListView_SetItemText(hwndLV, index, 2, _T(""));
ListView_SetItemText(hwndLV, index, 2, L"");
}
else
ListView_SetItemText(hwndLV, index, 2, _T(""));
ListView_SetItemText(hwndLV, index, 2, L"");
}
break;
case REG_DWORD:
{
TCHAR buf[200];
WCHAR buf[200];
if(dwCount == sizeof(DWORD))
{
wsprintf(buf, _T("0x%08x (%u)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf);
wsprintf(buf, L"0x%08x (%u)", *(DWORD*)ValBuf, *(DWORD*)ValBuf);
}
else
{
LoadString(hInst, IDS_INVALID_DWORD, buf, COUNT_OF(buf));
LoadStringW(hInst, IDS_INVALID_DWORD, buf, COUNT_OF(buf));
}
ListView_SetItemText(hwndLV, index, 2, buf);
}
@ -226,13 +226,13 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
{
unsigned int i;
LPBYTE pData = (LPBYTE)ValBuf;
LPTSTR strBinary;
LPWSTR strBinary;
if(dwCount > 0)
{
strBinary = HeapAlloc(GetProcessHeap(), 0, (dwCount * sizeof(TCHAR) * 3) + sizeof(TCHAR));
strBinary = HeapAlloc(GetProcessHeap(), 0, (dwCount * sizeof(WCHAR) * 3) + sizeof(WCHAR));
for (i = 0; i < dwCount; i++)
{
wsprintf( strBinary + i*3, _T("%02X "), pData[i] );
wsprintf( strBinary + i*3, L"%02X ", pData[i] );
}
strBinary[dwCount * 3] = 0;
ListView_SetItemText(hwndLV, index, 2, strBinary);
@ -240,8 +240,8 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
}
else
{
TCHAR szText[128];
LoadString(hInst, IDS_BINARY_EMPTY, szText, COUNT_OF(szText));
WCHAR szText[128];
LoadStringW(hInst, IDS_BINARY_EMPTY, szText, COUNT_OF(szText));
ListView_SetItemText(hwndLV, index, 2, szText);
}
}
@ -252,9 +252,9 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
static BOOL CreateListColumns(HWND hWndListView)
{
TCHAR szText[50];
WCHAR szText[50];
int index;
LV_COLUMN lvC;
LVCOLUMN lvC;
/* Create columns. */
lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
@ -266,7 +266,7 @@ static BOOL CreateListColumns(HWND hWndListView)
lvC.iSubItem = index;
lvC.cx = default_column_widths[index];
lvC.fmt = column_alignment[index];
LoadString(hInst, IDS_LIST_COLUMN_FIRST + index, szText, COUNT_OF(szText));
LoadStringW(hInst, IDS_LIST_COLUMN_FIRST + index, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hWndListView, index, &lvC) == -1) return FALSE;
}
return TRUE;
@ -282,10 +282,10 @@ static BOOL InitListViewImageLists(HWND hwndLV)
ILC_MASK, 0, NUM_ICONS)) == NULL)
return FALSE;
hico = LoadIcon(hInst, MAKEINTRESOURCE(IDI_BIN));
hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_BIN));
Image_Bin = ImageList_AddIcon(himl, hico);
hico = LoadIcon(hInst, MAKEINTRESOURCE(IDI_STRING));
hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_STRING));
Image_String = ImageList_AddIcon(himl, hico);
@ -305,7 +305,7 @@ static BOOL InitListViewImageLists(HWND hwndLV)
static void OnGetDispInfo(NMLVDISPINFO* plvdi)
{
static TCHAR buffer[200];
static WCHAR buffer[200];
plvdi->item.pszText = NULL;
plvdi->item.cchTextMax = 0;
@ -313,60 +313,60 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
switch (plvdi->item.iSubItem)
{
case 0:
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer));
LoadStringW(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer));
plvdi->item.pszText = buffer;
break;
case 1:
switch (((LINE_INFO*)plvdi->item.lParam)->dwValType)
{
case REG_NONE:
plvdi->item.pszText = _T("REG_NONE");
break;
case REG_SZ:
plvdi->item.pszText = _T("REG_SZ");
break;
case REG_EXPAND_SZ:
plvdi->item.pszText = _T("REG_EXPAND_SZ");
break;
case REG_BINARY:
plvdi->item.pszText = _T("REG_BINARY");
break;
case REG_DWORD: /* REG_DWORD_LITTLE_ENDIAN */
plvdi->item.pszText = _T("REG_DWORD");
break;
case REG_DWORD_BIG_ENDIAN:
plvdi->item.pszText = _T("REG_DWORD_BIG_ENDIAN");
break;
case REG_LINK:
plvdi->item.pszText = _T("REG_LINK");
break;
case REG_MULTI_SZ:
plvdi->item.pszText = _T("REG_MULTI_SZ");
break;
case REG_RESOURCE_LIST:
plvdi->item.pszText = _T("REG_RESOURCE_LIST");
break;
case REG_FULL_RESOURCE_DESCRIPTOR:
plvdi->item.pszText = _T("REG_FULL_RESOURCE_DESCRIPTOR");
break;
case REG_RESOURCE_REQUIREMENTS_LIST:
plvdi->item.pszText = _T("REG_RESOURCE_REQUIREMENTS_LIST");
break;
case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
plvdi->item.pszText = _T("REG_QWORD");
break;
default:
{
TCHAR buf2[200];
LoadString(hInst, IDS_UNKNOWN_TYPE, buf2, COUNT_OF(buf2));
wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType);
plvdi->item.pszText = buffer;
break;
}
case REG_NONE:
plvdi->item.pszText = L"REG_NONE";
break;
case REG_SZ:
plvdi->item.pszText = L"REG_SZ";
break;
case REG_EXPAND_SZ:
plvdi->item.pszText = L"REG_EXPAND_SZ";
break;
case REG_BINARY:
plvdi->item.pszText = L"REG_BINARY";
break;
case REG_DWORD: /* REG_DWORD_LITTLE_ENDIAN */
plvdi->item.pszText = L"REG_DWORD";
break;
case REG_DWORD_BIG_ENDIAN:
plvdi->item.pszText = L"REG_DWORD_BIG_ENDIAN";
break;
case REG_LINK:
plvdi->item.pszText = L"REG_LINK";
break;
case REG_MULTI_SZ:
plvdi->item.pszText = L"REG_MULTI_SZ";
break;
case REG_RESOURCE_LIST:
plvdi->item.pszText = L"REG_RESOURCE_LIST";
break;
case REG_FULL_RESOURCE_DESCRIPTOR:
plvdi->item.pszText = L"REG_FULL_RESOURCE_DESCRIPTOR";
break;
case REG_RESOURCE_REQUIREMENTS_LIST:
plvdi->item.pszText = L"REG_RESOURCE_REQUIREMENTS_LIST";
break;
case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
plvdi->item.pszText = L"REG_QWORD";
break;
default:
{
WCHAR buf2[200];
LoadStringW(hInst, IDS_UNKNOWN_TYPE, buf2, COUNT_OF(buf2));
wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType);
plvdi->item.pszText = buffer;
break;
}
}
break;
case 3:
plvdi->item.pszText = _T("");
plvdi->item.pszText = L"";
break;
}
}
@ -388,7 +388,7 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor
{
/* FIXME: Sort on value */
}
return g_invertSort ? _tcsicmp(r->name, l->name) : _tcsicmp(l->name, r->name);
return g_invertSort ? wcsicmp(r->name, l->name) : wcsicmp(l->name, r->name);
}
BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
@ -415,7 +415,7 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
case NM_DBLCLK:
case NM_RETURN:
{
SendMessage(hFrameWnd, WM_COMMAND, MAKEWPARAM(ID_EDIT_MODIFY, 0), 0);
SendMessageW(hFrameWnd, WM_COMMAND, MAKEWPARAM(ID_EDIT_MODIFY, 0), 0);
}
return TRUE;
case NM_SETFOCUS:
@ -426,7 +426,7 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
if(Info)
{
PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
if(!lineinfo->name || !_tcscmp(lineinfo->name, _T("")))
if(!lineinfo->name || !wcscmp(lineinfo->name, L""))
{
*Result = TRUE;
}
@ -443,32 +443,32 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
if(Info && Info->item.pszText)
{
PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
if(!lineinfo->name || !_tcscmp(lineinfo->name, _T("")))
if(!lineinfo->name || !wcscmp(lineinfo->name, L""))
{
*Result = FALSE;
}
else
{
if(_tcslen(Info->item.pszText) == 0)
if(wcslen(Info->item.pszText) == 0)
{
TCHAR msg[128], caption[128];
WCHAR msg[128], caption[128];
LoadString(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, COUNT_OF(msg));
LoadString(hInst, IDS_ERR_RENVAL_CAPTION, caption, COUNT_OF(caption));
MessageBox(0, msg, caption, 0);
LoadStringW(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, COUNT_OF(msg));
LoadStringW(hInst, IDS_ERR_RENVAL_CAPTION, caption, COUNT_OF(caption));
MessageBoxW(0, msg, caption, 0);
*Result = TRUE;
}
else
{
HKEY hKeyRoot;
LPCTSTR keyPath;
LPCWSTR keyPath;
LONG lResult;
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
lResult = RenameValue(hKeyRoot, keyPath, Info->item.pszText, lineinfo->name);
lineinfo->name = realloc(lineinfo->name, (_tcslen(Info->item.pszText)+1)*sizeof(TCHAR));
lineinfo->name = realloc(lineinfo->name, (wcslen(Info->item.pszText)+1)*sizeof(WCHAR));
if (lineinfo->name != NULL)
_tcscpy(lineinfo->name, Info->item.pszText);
wcscpy(lineinfo->name, Info->item.pszText);
*Result = TRUE;
return (lResult == ERROR_SUCCESS);
@ -491,10 +491,10 @@ HWND CreateListView(HWND hwndParent, HMENU id)
/* Get the dimensions of the parent window's client area, and create the list view control. */
GetClientRect(hwndParent, &rcClient);
hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"),
WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_REPORT | LVS_EDITLABELS,
0, 0, rcClient.right, rcClient.bottom,
hwndParent, id, hInst, NULL);
hwndLV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEW, L"List View",
WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_REPORT | LVS_EDITLABELS,
0, 0, rcClient.right, rcClient.bottom,
hwndParent, id, hInst, NULL);
if (!hwndLV) return NULL;
/* Initialize the image list, and add items to the control. */
@ -524,7 +524,7 @@ void DestroyListView(HWND hwndLV)
}
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
{
DWORD max_sub_key_len;
DWORD max_val_name_len;
@ -539,7 +539,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
(void)ListView_EditLabel(hwndLV, -1);
SendMessage(hwndLV, WM_SETREDRAW, FALSE, 0);
SendMessageW(hwndLV, WM_SETREDRAW, FALSE, 0);
DestroyListView(hwndLV);
g_columnToSort = ~0UL;
@ -547,38 +547,36 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
if(!hKey) return FALSE;
errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey);
errCode = RegOpenKeyExW(hKey, keyPath, 0, KEY_READ, &hNewKey);
if (errCode != ERROR_SUCCESS) return FALSE;
/* get size information and resize the buffers if necessary */
errCode = RegQueryInfoKey(hNewKey, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL,
&val_count, &max_val_name_len, &max_val_size, NULL, NULL);
errCode = RegQueryInfoKeyW(hNewKey, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL,
&val_count, &max_val_name_len, &max_val_size, NULL, NULL);
if (errCode == ERROR_SUCCESS)
{
TCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(TCHAR));
WCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(WCHAR));
DWORD dwValNameLen = max_val_name_len;
BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, max_val_size + sizeof(TCHAR));
BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, max_val_size + sizeof(WCHAR));
DWORD dwValSize = max_val_size;
DWORD dwIndex = 0L;
DWORD dwValType;
/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
/* if (RegQueryValueExW(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
/* AddEntryToList(hwndLV, L"(Default)", dwValType, ValBuf, dwValSize); */
/* } */
/* dwValSize = max_val_size; */
while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS)
while (RegEnumValueW(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS)
{
/* Add a terminating 0 character. Usually this is only necessary for strings. */
ValBuf[dwValSize] = 0;
#ifdef UNICODE
ValBuf[dwValSize + 1] = 0;
#endif
ValBuf[dwValSize] = ValBuf[dwValSize + 1] = 0;
AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize, -1, TRUE);
dwValNameLen = max_val_name_len;
dwValSize = max_val_size;
dwValType = 0L;
++dwIndex;
if(!_tcscmp(ValName, _T("")))
if(!wcscmp(ValName, L""))
{
AddedDefault = TRUE;
}
@ -588,7 +586,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
}
if(!AddedDefault)
{
AddEntryToList(hwndLV, _T(""), REG_SZ, NULL, 0, 0, FALSE);
AddEntryToList(hwndLV, L"", REG_SZ, NULL, 0, 0, FALSE);
}
ListView_SortItems(hwndLV, CompareFunc, (WPARAM)hwndLV);
c = ListView_GetItemCount(hwndLV);
@ -600,7 +598,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
LVIS_FOCUSED | LVIS_SELECTED,
LVIS_FOCUSED | LVIS_SELECTED);
RegCloseKey(hNewKey);
SendMessage(hwndLV, WM_SETREDRAW, TRUE, 0);
SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0);
return TRUE;
}

View file

@ -33,12 +33,12 @@ HWND hStatusBar;
HMENU hMenuFrame;
HMENU hPopupMenus = 0;
UINT nClipboardFormat;
LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT");
LPCWSTR strClipboardFormat = L"TODO: SET CORRECT FORMAT";
#define MAX_LOADSTRING 100
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szFrameClass[MAX_LOADSTRING];
TCHAR szChildClass[MAX_LOADSTRING];
WCHAR szTitle[MAX_LOADSTRING];
WCHAR szFrameClass[MAX_LOADSTRING];
WCHAR szChildClass[MAX_LOADSTRING];
/*******************************************************************************
@ -59,43 +59,44 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
BOOL AclUiAvailable;
HMENU hEditMenu;
WNDCLASSEX wcFrame;
WNDCLASSEX wcChild;
WNDCLASSEXW wcFrame;
WNDCLASSEXW wcChild;
ATOM hFrameWndClass;
ZeroMemory(&wcFrame, sizeof(WNDCLASSEX));
wcFrame.cbSize = sizeof(WNDCLASSEX);
ZeroMemory(&wcFrame, sizeof(WNDCLASSEXW));
wcFrame.cbSize = sizeof(WNDCLASSEXW);
wcFrame.lpfnWndProc = FrameWndProc;
wcFrame.hInstance = hInstance;
wcFrame.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT));
wcFrame.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT),
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
wcFrame.hCursor = LoadCursor(0, IDC_ARROW);
wcFrame.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
wcFrame.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT),
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
wcFrame.hCursor = LoadCursorW(NULL, IDC_ARROW);
wcFrame.lpszClassName = szFrameClass;
hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */
hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */
ZeroMemory(&wcChild, sizeof(WNDCLASSEX));
wcChild.cbSize = sizeof(WNDCLASSEX);
ZeroMemory(&wcChild, sizeof(WNDCLASSEXW));
wcChild.cbSize = sizeof(WNDCLASSEXW);
wcChild.lpfnWndProc = ChildWndProc;
wcChild.cbWndExtra = sizeof(HANDLE);
wcChild.hInstance = hInstance;
wcChild.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT));
wcChild.hCursor = LoadCursor(0, IDC_ARROW);
wcChild.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
wcChild.hCursor = LoadCursorW(NULL, IDC_ARROW);
wcChild.lpszClassName = szChildClass;
wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT),
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
wcChild.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT),
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
RegisterClassEx(&wcChild); /* register child windows class */
RegisterClassExW(&wcChild); /* register child windows class */
RegisterHexEditorClass(hInstance);
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
hPopupMenus = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_MENUS));
hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU));
hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));
/* Initialize the Windows Common Controls DLL */
// TODO: Replace this call by InitCommonControlsEx(_something_)
InitCommonControls();
hEditMenu = GetSubMenu(hMenuFrame, 1);
@ -115,15 +116,15 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
if(hEditMenu != NULL)
SetMenuDefaultItem(hEditMenu, ID_EDIT_MODIFY, MF_BYCOMMAND);
nClipboardFormat = RegisterClipboardFormat(strClipboardFormat);
nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat);
/* if (nClipboardFormat == 0) {
DWORD dwError = GetLastError();
} */
hFrameWnd = CreateWindowEx(WS_EX_WINDOWEDGE, (LPCTSTR)(UlongToPtr(hFrameWndClass)), szTitle,
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
hFrameWnd = CreateWindowExW(WS_EX_WINDOWEDGE, (LPCWSTR)(UlongToPtr(hFrameWndClass)), szTitle,
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
if (!hFrameWnd)
{
@ -131,13 +132,13 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
}
/* Create the status bar */
hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|SBT_NOBORDERS,
_T(""), hFrameWnd, STATUS_WINDOW);
hStatusBar = CreateStatusWindowW(WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | SBT_NOBORDERS,
L"", hFrameWnd, STATUS_WINDOW);
if (hStatusBar)
{
/* Create the status bar panes */
SetupStatusBar(hFrameWnd, FALSE);
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND | MF_CHECKED);
}
LoadSettings();
@ -147,8 +148,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
/******************************************************************************/
/* we need to destroy the main menu before destroying the main window
to avoid a memory leak */
/*
* We need to destroy the main menu before destroying the main window
* to avoid a memory leak.
*/
void DestroyMainMenu()
{
@ -165,22 +168,22 @@ void ExitInstance(HINSTANCE hInstance)
UnloadAclUiDll();
}
BOOL TranslateChildTabMessage(MSG *msg)
BOOL TranslateChildTabMessage(PMSG msg)
{
if (msg->message != WM_KEYDOWN) return FALSE;
/* Allow Ctrl+A on address bar */
if ((msg->hwnd == g_pChildWnd->hAddressBarWnd) &&
(msg->message == WM_KEYDOWN) &&
(msg->wParam == 'A') && (GetKeyState(VK_CONTROL) < 0))
(msg->wParam == L'A') && (GetKeyState(VK_CONTROL) < 0))
{
SendMessage(msg->hwnd, EM_SETSEL, 0, -1);
SendMessageW(msg->hwnd, EM_SETSEL, 0, -1);
return TRUE;
}
if (msg->wParam != VK_TAB) return FALSE;
if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
PostMessage(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
PostMessageW(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
return TRUE;
}
@ -194,15 +197,16 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
UNREFERENCED_PARAMETER(hPrevInstance);
InfoMessageBox(NULL, MB_OK | MB_ICONERROR, L"Main", L"Main '%1'", lpCmdLine);
if (ProcessCmdLine(lpCmdLine))
{
return 0;
}
/* Initialize global strings */
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
LoadString(hInstance, IDC_REGEDIT, szChildClass, MAX_LOADSTRING);
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_REGEDIT, szChildClass, MAX_LOADSTRING);
/* Store instance handle in our global variable */
hInst = hInstance;
@ -212,19 +216,21 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
{
return FALSE;
}
hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCEL));
hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(ID_ACCEL));
/* Main message loop */
while (GetMessage(&msg, (HWND)NULL, 0, 0))
while (GetMessageW(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(hFrameWnd, hAccel, &msg)
&& !TranslateChildTabMessage(&msg))
if (!TranslateAcceleratorW(hFrameWnd, hAccel, &msg) &&
!TranslateChildTabMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
DispatchMessageW(&msg);
}
}
ExitInstance(hInstance);
return (int) msg.wParam;
return (int)msg.wParam;
}
/* EOF */

View file

@ -45,13 +45,13 @@ extern HINSTANCE hInst;
enum OPTION_FLAGS
{
OPTIONS_AUTO_REFRESH = 0x01,
OPTIONS_READ_ONLY_MODE = 0x02,
OPTIONS_CONFIRM_ON_DELETE = 0x04,
OPTIONS_SAVE_ON_EXIT = 0x08,
OPTIONS_DISPLAY_BINARY_DATA = 0x10,
OPTIONS_VIEW_TREE_ONLY = 0x20,
OPTIONS_VIEW_DATA_ONLY = 0x40,
OPTIONS_AUTO_REFRESH = 0x01,
OPTIONS_READ_ONLY_MODE = 0x02,
OPTIONS_CONFIRM_ON_DELETE = 0x04,
OPTIONS_SAVE_ON_EXIT = 0x08,
OPTIONS_DISPLAY_BINARY_DATA = 0x10,
OPTIONS_VIEW_TREE_ONLY = 0x20,
OPTIONS_VIEW_DATA_ONLY = 0x40,
};
typedef struct
@ -62,9 +62,9 @@ typedef struct
HWND hAddressBarWnd;
HWND hAddressBtnWnd;
int nFocusPanel; /* 0: left 1: right */
int nSplitPos;
int nSplitPos;
WINDOWPLACEMENT pos;
TCHAR szPath[MAX_PATH];
WCHAR szPath[MAX_PATH];
} ChildWnd;
extern ChildWnd* g_pChildWnd;
@ -79,11 +79,11 @@ extern HMENU hPopupMenus;
extern HFONT hFont;
extern enum OPTION_FLAGS Options;
extern TCHAR szTitle[];
extern TCHAR szFrameClass[];
extern TCHAR szChildClass[];
extern WCHAR szTitle[];
extern WCHAR szFrameClass[];
extern WCHAR szChildClass[];
extern const TCHAR g_szGeneralRegKey[];
extern const WCHAR g_szGeneralRegKey[];
/* about.c */
extern void ShowAboutBox(HWND hWnd);
@ -91,11 +91,11 @@ extern void ShowAboutBox(HWND hWnd);
/* childwnd.c */
extern LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
extern void ResizeWnd(int cx, int cy);
extern LPCTSTR get_root_key_name(HKEY hRootKey);
extern LPCWSTR get_root_key_name(HKEY hRootKey);
/* error.c */
extern int ErrorMessageBox(HWND hWnd, LPCTSTR lpTitle, DWORD dwErrorCode, ...);
extern int InfoMessageBox(HWND hWnd, UINT uType, LPCTSTR lpTitle, LPCTSTR lpMessage, ...);
extern int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode, ...);
extern int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage, ...);
/* find.c */
extern void FindDialog(HWND hWnd);
@ -105,42 +105,47 @@ extern BOOL FindNext(HWND hWnd);
extern LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);
extern void SetupStatusBar(HWND hWnd, BOOL bResize);
extern void UpdateStatusBar(void);
extern BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCTSTR keyName);
extern BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName);
extern BOOL ExportRegistryFile(HWND hWnd);
/* listview.c */
extern HWND CreateListView(HWND hwndParent, HMENU id);
extern BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath);
extern LPCTSTR GetValueName(HWND hwndLV, int iStartAt);
extern BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath);
extern LPCWSTR GetValueName(HWND hwndLV, int iStartAt);
extern BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result);
extern BOOL IsDefaultValue(HWND hwndLV, int i);
/* regedit.c */
LPCWSTR getAppName(void);
/* treeview.c */
extern HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, HMENU id);
extern HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, HMENU id);
extern BOOL RefreshTreeView(HWND hWndTV);
extern BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem);
extern BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);
extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
extern LPCWSTR GetItemPath(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 BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem);
extern BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath);
extern BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath);
extern void DestroyTreeView( void );
extern void DestroyListView( HWND hwndLV );
extern void DestroyMainMenu( void );
/* edit.c */
extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin);
extern BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath);
extern LONG RenameKey(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpNewName);
extern LONG RenameValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpDestValue, LPCTSTR lpSrcValue);
extern LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen);
extern BOOL GetKeyName(LPTSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCTSTR lpSubKey);
extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin);
extern BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath);
extern LONG RenameKey(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpNewName);
extern LONG RenameValue(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpDestValue, LPCWSTR lpSrcValue);
extern LONG QueryStringValue(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR pszBuffer, DWORD dwBufferLen);
extern BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey);
/* security.c */
extern BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCTSTR lpMachine, LPCTSTR lpKeyName);
extern BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCWSTR lpMachine, LPCWSTR lpKeyName);
/* settings.c */
extern void LoadSettings(void);
extern void SaveSettings(void);
/* EOF */

View file

@ -21,37 +21,37 @@
#include <regedit.h>
static const char *usage =
"Usage:\n"
" regedit filenames\n"
" regedit /E filename [regpath]\n"
" regedit /D regpath\n"
"\n"
"filenames - List of registry files names\n"
"filename - Registry file name\n"
"regpath - Name of the registry key\n"
"\n"
"When is called without any switches adds contents of the specified\n"
"registry files to the registry.\n"
"\n"
"Switches:\n"
" /E - Exports contents of the specified registry key to the specified\n"
" file. Exports the whole registry if no key is specified.\n"
" /D - Deletes specified registry key\n"
" /S - Silent execution, can be used with any other switch.\n"
" The only existing mode, exists for compatibility with Windows regedit.\n"
" /V - Advanced mode, can be used with any other switch.\n"
" Ignored, exists for compatibility with Windows regedit.\n"
" /L - Location of system.dat file. Can be used with any other switch.\n"
" Ignored. Exists for compatibility with Windows regedit.\n"
" /R - Location of user.dat file. Can be used with any other switch.\n"
" Ignored. Exists for compatibility with Windows regedit.\n"
" /? - Print this help. Any other switches are ignored.\n"
" /C - Create registry from. Not implemented.\n"
"\n"
"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
"This program is command-line compatible with Microsoft Windows\n"
"regedit.\n";
static const LPCWSTR usage =
L"Usage:\n"
L" regedit filenames\n"
L" regedit /E filename [regpath]\n"
L" regedit /D regpath\n"
L"\n"
L"filenames - List of registry files names\n"
L"filename - Registry file name\n"
L"regpath - Name of the registry key\n"
L"\n"
L"When is called without any switches adds contents of the specified\n"
L"registry files to the registry.\n"
L"\n"
L"Switches:\n"
L" /E - Exports contents of the specified registry key to the specified\n"
L" file. Exports the whole registry if no key is specified.\n"
L" /D - Deletes specified registry key\n"
L" /S - Silent execution, can be used with any other switch.\n"
L" The only existing mode, exists for compatibility with Windows regedit.\n"
L" /V - Advanced mode, can be used with any other switch.\n"
L" Ignored, exists for compatibility with Windows regedit.\n"
L" /L - Location of system.dat file. Can be used with any other switch.\n"
L" Ignored. Exists for compatibility with Windows regedit.\n"
L" /R - Location of user.dat file. Can be used with any other switch.\n"
L" Ignored. Exists for compatibility with Windows regedit.\n"
L" /? - Print this help. Any other switches are ignored.\n"
L" /C - Create registry from. Not implemented.\n"
L"\n"
L"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
L"This program is command-line compatible with Microsoft Windows\n"
L"regedit.\n";
typedef enum
{
@ -59,9 +59,9 @@ typedef enum
} REGEDIT_ACTION;
const CHAR *getAppName(void)
LPCWSTR getAppName(void)
{
return "regedit";
return L"regedit";
}
/******************************************************************************
@ -75,10 +75,10 @@ const CHAR *getAppName(void)
* where *s[0] is the first symbol of the file name.
* file_name - buffer to write the file name to.
*/
void get_file_name(LPTSTR *command_line, LPTSTR file_name)
void get_file_name(LPWSTR *command_line, LPWSTR file_name)
{
TCHAR *s = *command_line;
int pos = 0; /* position of pointer "s" in *command_line */
WCHAR *s = *command_line;
size_t pos = 0; /* position of pointer "s" in *command_line */
file_name[0] = 0;
if (!s[0])
@ -86,15 +86,15 @@ void get_file_name(LPTSTR *command_line, LPTSTR file_name)
return;
}
if (s[0] == _T('"'))
if (s[0] == L'"')
{
s++;
(*command_line)++;
while(s[0] != _T('"'))
while(s[0] != L'"')
{
if (!s[0])
{
fprintf(stderr, "%s: Unexpected end of file name!\n", getAppName());
fwprintf(stderr, L"%s: Unexpected end of file name!\n", getAppName());
exit(1);
}
s++;
@ -103,7 +103,7 @@ void get_file_name(LPTSTR *command_line, LPTSTR file_name)
}
else
{
while(s[0] && !_istspace(s[0]))
while(s[0] && !iswspace(s[0]))
{
s++;
pos++;
@ -111,13 +111,13 @@ void get_file_name(LPTSTR *command_line, LPTSTR file_name)
}
memcpy(file_name, *command_line, pos * sizeof(WCHAR));
/* remove the last backslash */
if (file_name[pos - 1] == _T('\\'))
if (file_name[pos - 1] == L'\\')
{
file_name[pos - 1] = _T('\0');
file_name[pos - 1] = L'\0';
}
else
{
file_name[pos] = _T('\0');
file_name[pos] = L'\0';
}
if (s[0])
@ -125,7 +125,7 @@ void get_file_name(LPTSTR *command_line, LPTSTR file_name)
s++;
pos++;
}
while(s[0] && _istspace(s[0]))
while(s[0] && iswspace(s[0]))
{
s++;
pos++;
@ -133,38 +133,39 @@ void get_file_name(LPTSTR *command_line, LPTSTR file_name)
(*command_line) += pos;
}
BOOL PerformRegAction(REGEDIT_ACTION action, LPTSTR s, BOOL silent)
BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s, BOOL silent)
{
switch (action)
{
case ACTION_ADD:
{
TCHAR szTitle[512], szText[512];
TCHAR filename[MAX_PATH];
WCHAR szTitle[512], szText[512];
WCHAR filename[MAX_PATH];
FILE *fp;
get_file_name(&s, filename);
if (!filename[0])
{
fprintf(stderr, "%s: No file name is specified\n", getAppName());
fprintf(stderr, usage);
fwprintf(stderr, L"%s: No file name is specified\n", getAppName());
// fwprintf(stderr, usage);
MessageBoxW(NULL, usage, NULL, MB_OK | MB_ICONINFORMATION);
exit(4);
}
LoadString(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
while (filename[0])
{
/* Request import confirmation */
if (!silent)
{
LoadString(hInst, IDS_IMPORT_PROMPT, szText, COUNT_OF(szText));
LoadStringW(hInst, IDS_IMPORT_PROMPT, szText, COUNT_OF(szText));
if (InfoMessageBox(NULL, MB_YESNO | MB_ICONWARNING, szTitle, szText, filename) != IDYES)
goto cont;
}
fp = _tfopen(filename, _T("r"));
fp = _wfopen(filename, L"r");
if (fp != NULL)
{
import_registry_file(fp);
@ -172,7 +173,7 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPTSTR s, BOOL silent)
/* Show successful import */
if (!silent)
{
LoadString(hInst, IDS_IMPORT_OK, szText, COUNT_OF(szText));
LoadStringW(hInst, IDS_IMPORT_OK, szText, COUNT_OF(szText));
InfoMessageBox(NULL, MB_OK | MB_ICONINFORMATION, szTitle, szText, filename);
}
@ -180,15 +181,15 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPTSTR s, BOOL silent)
}
else
{
LPSTR p = GetMultiByteString(filename);
perror("");
fprintf(stderr, "%s: Can't open file \"%s\"\n", getAppName(), p);
HeapFree(GetProcessHeap(), 0, p);
//LPSTR p = GetMultiByteString(filename);
//perror("");
fwprintf(stderr, L"%s: Can't open file \"%s\"\n", getAppName(), filename /*p*/);
//HeapFree(GetProcessHeap(), 0, p);
/* Error opening the file */
if (!silent)
{
LoadString(hInst, IDS_IMPORT_ERROR, szText, COUNT_OF(szText));
LoadStringW(hInst, IDS_IMPORT_ERROR, szText, COUNT_OF(szText));
InfoMessageBox(NULL, MB_OK | MB_ICONERROR, szTitle, szText, filename);
}
}
@ -201,12 +202,13 @@ cont:
case ACTION_DELETE:
{
TCHAR reg_key_name[KEY_MAX_LEN];
WCHAR reg_key_name[KEY_MAX_LEN];
get_file_name(&s, reg_key_name);
if (!reg_key_name[0])
{
fprintf(stderr, "%s: No registry key is specified for removal\n", getAppName());
fprintf(stderr, usage);
fwprintf(stderr, L"%s: No registry key is specified for removal\n", getAppName());
// fwprintf(stderr, usage);
MessageBoxW(NULL, usage, NULL, MB_OK | MB_ICONINFORMATION);
exit(6);
}
delete_registry_key(reg_key_name);
@ -215,20 +217,21 @@ cont:
case ACTION_EXPORT:
{
TCHAR filename[MAX_PATH];
WCHAR filename[MAX_PATH];
filename[0] = _T('\0');
filename[0] = L'\0';
get_file_name(&s, filename);
if (!filename[0])
{
fprintf(stderr, "%s: No file name is specified\n", getAppName());
fprintf(stderr, usage);
fwprintf(stderr, L"%s: No file name is specified\n", getAppName());
// fwprintf(stderr, usage);
MessageBoxW(NULL, usage, NULL, MB_OK | MB_ICONINFORMATION);
exit(7);
}
if (s[0])
{
TCHAR reg_key_name[KEY_MAX_LEN];
WCHAR reg_key_name[KEY_MAX_LEN];
get_file_name(&s, reg_key_name);
export_registry_key(filename, reg_key_name, REG_FORMAT_4);
}
@ -240,7 +243,7 @@ cont:
}
default:
fprintf(stderr, "%s: Unhandled action!\n", getAppName());
fwprintf(stderr, L"%s: Unhandled action!\n", getAppName());
exit(8);
break;
}
@ -259,40 +262,40 @@ static void error_unknown_switch(WCHAR chu, LPWSTR s)
{
if (iswalpha(chu))
{
fprintf(stderr, "%s: Undefined switch /%c!\n", getAppName(), chu);
fwprintf(stderr, L"%s: Undefined switch /%c!\n", getAppName(), chu);
}
else
{
fprintf(stderr, "%s: Alphabetic character is expected after '%c' "
"in switch specification\n", getAppName(), *(s - 1));
fwprintf(stderr, L"%s: Alphabetic character is expected after '%c' "
L"in switch specification\n", getAppName(), *(s - 1));
}
exit(1);
}
BOOL ProcessCmdLine(LPTSTR lpCmdLine)
BOOL ProcessCmdLine(LPWSTR lpCmdLine)
{
BOOL silent = FALSE;
REGEDIT_ACTION action = ACTION_UNDEF;
LPTSTR s = lpCmdLine; /* command line pointer */
TCHAR ch = *s; /* current character */
LPWSTR s = lpCmdLine; /* command line pointer */
WCHAR ch = *s; /* current character */
while (ch && ((ch == _T('-')) || (ch == _T('/'))))
while (ch && ((ch == L'-') || (ch == L'/')))
{
TCHAR chu;
TCHAR ch2;
WCHAR chu;
WCHAR ch2;
s++;
ch = *s;
ch2 = *(s + 1);
chu = _totupper(ch);
if (!ch2 || _istspace(ch2))
chu = towupper(ch);
if (!ch2 || iswspace(ch2))
{
if (chu == _T('S'))
if (chu == L'S')
{
/* Silence dialogs */
silent = TRUE;
}
else if (chu == _T('V'))
else if (chu == L'V')
{
/* Ignore this switch */
}
@ -300,14 +303,15 @@ BOOL ProcessCmdLine(LPTSTR lpCmdLine)
{
switch (chu)
{
case _T('D'):
case L'D':
action = ACTION_DELETE;
break;
case _T('E'):
case L'E':
action = ACTION_EXPORT;
break;
case _T('?'):
fprintf(stderr, usage);
case L'?':
//fwprintf(stderr, usage);
MessageBoxW(NULL, usage, NULL, MB_OK | MB_ICONINFORMATION);
exit(3);
break;
default:
@ -319,15 +323,15 @@ BOOL ProcessCmdLine(LPTSTR lpCmdLine)
}
else
{
if (ch2 == _T(':'))
if (ch2 == L':')
{
switch (chu)
{
case _T('L'):
case L'L':
/* fall through */
case _T('R'):
case L'R':
s += 2;
while (*s && !_istspace(*s))
while (*s && !iswspace(*s))
{
s++;
}
@ -346,7 +350,7 @@ BOOL ProcessCmdLine(LPTSTR lpCmdLine)
}
/* skip spaces to the next parameter */
ch = *s;
while (ch && _istspace(ch))
while (ch && iswspace(ch))
{
s++;
ch = *s;

View file

@ -12,7 +12,7 @@
#include <shellapi.h>
#include <shlwapi.h>
#include <stdlib.h>
#include <tchar.h>
//#include <tchar.h>
#include <process.h>
#include <stdio.h>
#include <limits.h>
@ -29,4 +29,7 @@
#include "regproc.h"
#include "hexedit.h"
#include "security.h"
#endif
/* EOF */

View file

@ -60,7 +60,7 @@ static HKEY reg_class_keys[REG_CLASS_NUMBER] =
#define CHECK_ENOUGH_MEMORY(p) \
if (!(p)) \
{ \
fprintf(stderr,"%s: file %s, line %d: Not enough memory\n", \
fprintf(stderr,"%S: file %s, line %d: Not enough memory\n", \
getAppName(), __FILE__, __LINE__); \
exit(NOT_ENOUGH_MEMORY); \
}
@ -154,7 +154,7 @@ static BOOL convertHexToDWord(WCHAR* str, DWORD *dw)
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL);
if (lstrlenW(str) > 8 || sscanf(buf, "%lx%c", dw, &dummy) != 1)
{
fprintf(stderr,"%s: ERROR, invalid hex value\n", getAppName());
fprintf(stderr,"%S: ERROR, invalid hex value\n", getAppName());
return FALSE;
}
return TRUE;
@ -185,7 +185,7 @@ static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size)
if (end == s || wc > 0xff || (*end && *end != L','))
{
char* strA = GetMultiByteString(s);
fprintf(stderr,"%s: ERROR converting CSV hex stream. Invalid value at '%s'\n",
fprintf(stderr,"%S: ERROR converting CSV hex stream. Invalid value at '%s'\n",
getAppName(), strA);
HeapFree(GetProcessHeap(), 0, data);
HeapFree(GetProcessHeap(), 0, strA);
@ -423,7 +423,7 @@ static LONG setValue(WCHAR* val_name, WCHAR* val_data, BOOL is_unicode)
}
else /* unknown format */
{
fprintf(stderr,"%s: ERROR, unknown data format\n", getAppName());
fprintf(stderr,"%S: ERROR, unknown data format\n", getAppName());
return ERROR_INVALID_DATA;
}
@ -573,7 +573,7 @@ static void processSetValue(WCHAR* line, BOOL is_unicode)
{
char* val_nameA = GetMultiByteString(val_name);
char* val_dataA = GetMultiByteString(val_data);
fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n",
fprintf(stderr,"%S: ERROR Key %s not created. Value: %s, Data: %s\n",
getAppName(),
currentKeyName,
val_nameA,
@ -619,7 +619,7 @@ static void processRegEntry(WCHAR* stdInput, BOOL isUnicode)
else if ( openKeyW(stdInput) != ERROR_SUCCESS )
{
char* stdInputA = GetMultiByteString(stdInput);
fprintf(stderr,"%s: setValue failed to open key %s\n",
fprintf(stderr,"%S: setValue failed to open key %s\n",
getAppName(), stdInputA);
HeapFree(GetProcessHeap(), 0, stdInputA);
}
@ -750,7 +750,7 @@ static void processRegLinesA(FILE *in)
if(c == EOF)
{
fprintf(stderr,"%s: ERROR - invalid continuation.\n",
fprintf(stderr,"%S: ERROR - invalid continuation.\n",
getAppName());
}
else
@ -923,7 +923,7 @@ static void REGPROC_print_error(void)
NULL, error_code, 0, (LPTSTR) &lpMsgBuf, 0, NULL);
if (!status)
{
fprintf(stderr,"%s: Cannot display message for error %ld, status %ld\n",
fprintf(stderr,"%S: Cannot display message for error %ld, status %ld\n",
getAppName(), error_code, GetLastError());
exit(1);
}
@ -1262,7 +1262,7 @@ BOOL unicode)
{
char* key_nameA = GetMultiByteString(*reg_key_name_buf);
char* value_nameA = GetMultiByteString(*val_name_buf);
fprintf(stderr,"%s: warning - unsupported registry format '%ld', "
fprintf(stderr,"%S: warning - unsupported registry format '%ld', "
"treat as binary\n",
getAppName(), value_type);
fprintf(stderr,"key name: \"%s\"\n", key_nameA);
@ -1345,7 +1345,7 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
{
CHAR* file_nameA = GetMultiByteString(file_name);
perror("");
fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), file_nameA);
fprintf(stderr,"%S: Can't open file \"%s\"\n", getAppName(), file_nameA);
HeapFree(GetProcessHeap(), 0, file_nameA);
exit(1);
}
@ -1408,7 +1408,7 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
if (!parseKeyName(reg_key_name, &reg_key_class, &branch_name))
{
CHAR* key_nameA = GetMultiByteString(reg_key_name);
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
fprintf(stderr,"%S: Incorrect registry class specification in '%s'\n",
getAppName(), key_nameA);
HeapFree(GetProcessHeap(), 0, key_nameA);
exit(1);
@ -1436,7 +1436,7 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
else
{
CHAR* key_nameA = GetMultiByteString(reg_key_name);
fprintf(stderr,"%s: Can't export. Registry key '%s' does not exist!\n",
fprintf(stderr,"%S: Can't export. Registry key '%s' does not exist!\n",
getAppName(), key_nameA);
HeapFree(GetProcessHeap(), 0, key_nameA);
REGPROC_print_error();
@ -1520,7 +1520,7 @@ void delete_registry_key(WCHAR *reg_key_name)
if (!parseKeyName(reg_key_name, &key_class, &key_name))
{
char* reg_key_nameA = GetMultiByteString(reg_key_name);
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
fprintf(stderr,"%S: Incorrect registry class specification in '%s'\n",
getAppName(), reg_key_nameA);
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
exit(1);
@ -1528,7 +1528,7 @@ void delete_registry_key(WCHAR *reg_key_name)
if (!*key_name)
{
char* reg_key_nameA = GetMultiByteString(reg_key_name);
fprintf(stderr,"%s: Can't delete registry class '%s'\n",
fprintf(stderr,"%S: Can't delete registry class '%s'\n",
getAppName(), reg_key_nameA);
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
exit(1);

View file

@ -22,8 +22,6 @@
#define REG_FORMAT_5 1
#define REG_FORMAT_4 2
const CHAR *getAppName(void);
BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format);
BOOL import_registry_file(FILE* reg_file);
void delete_registry_key(LPTSTR reg_key_name);

View file

@ -293,5 +293,4 @@
#define ID_ACCEL 3000
#define IDC_STATIC -1

View file

@ -336,18 +336,18 @@ static const struct ifaceISecurityObjectTypeInfoVbtl vtblISecurityObjectTypeInfo
******************************************************************************/
static SI_ACCESS RegAccess[] = {
{&GUID_NULL, KEY_ALL_ACCESS, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_FULLCONTROL), SI_ACCESS_GENERAL | SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_READ, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_READ), SI_ACCESS_GENERAL},
{&GUID_NULL, KEY_QUERY_VALUE, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_QUERYVALUE), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_SET_VALUE, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_SETVALUE), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_CREATE_SUB_KEY, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_CREATESUBKEY), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_ENUMERATE_SUB_KEYS, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_ENUMERATESUBKEYS), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_NOTIFY, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_NOTIFY), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_CREATE_LINK, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_CREATELINK), SI_ACCESS_SPECIFIC},
{&GUID_NULL, DELETE, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_DELETE), SI_ACCESS_SPECIFIC},
{&GUID_NULL, WRITE_DAC, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_WRITEDAC), SI_ACCESS_SPECIFIC},
{&GUID_NULL, WRITE_OWNER, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_WRITEOWNER), SI_ACCESS_SPECIFIC},
{&GUID_NULL, READ_CONTROL, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_READCONTROL), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_ALL_ACCESS, MAKEINTRESOURCEW(IDS_ACCESS_FULLCONTROL), SI_ACCESS_GENERAL | SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_READ, MAKEINTRESOURCEW(IDS_ACCESS_READ), SI_ACCESS_GENERAL},
{&GUID_NULL, KEY_QUERY_VALUE, MAKEINTRESOURCEW(IDS_ACCESS_QUERYVALUE), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_SET_VALUE, MAKEINTRESOURCEW(IDS_ACCESS_SETVALUE), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_CREATE_SUB_KEY, MAKEINTRESOURCEW(IDS_ACCESS_CREATESUBKEY), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_ENUMERATE_SUB_KEYS, MAKEINTRESOURCEW(IDS_ACCESS_ENUMERATESUBKEYS), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_NOTIFY, MAKEINTRESOURCEW(IDS_ACCESS_NOTIFY), SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_CREATE_LINK, MAKEINTRESOURCEW(IDS_ACCESS_CREATELINK), SI_ACCESS_SPECIFIC},
{&GUID_NULL, DELETE, MAKEINTRESOURCEW(IDS_ACCESS_DELETE), SI_ACCESS_SPECIFIC},
{&GUID_NULL, WRITE_DAC, MAKEINTRESOURCEW(IDS_ACCESS_WRITEDAC), SI_ACCESS_SPECIFIC},
{&GUID_NULL, WRITE_OWNER, MAKEINTRESOURCEW(IDS_ACCESS_WRITEOWNER), SI_ACCESS_SPECIFIC},
{&GUID_NULL, READ_CONTROL, MAKEINTRESOURCEW(IDS_ACCESS_READCONTROL), SI_ACCESS_SPECIFIC},
};
static const DWORD RegDefaultAccess = 1; /* KEY_READ */
@ -360,9 +360,9 @@ static GENERIC_MAPPING RegAccessMasks = {
};
static SI_INHERIT_TYPE RegInheritTypes[] = {
{&GUID_NULL, 0, (LPWSTR)MAKEINTRESOURCE(IDS_INHERIT_THISKEYONLY)},
{&GUID_NULL, CONTAINER_INHERIT_ACE, (LPWSTR)MAKEINTRESOURCE(IDS_INHERIT_THISKEYANDSUBKEYS)},
{&GUID_NULL, INHERIT_ONLY_ACE | CONTAINER_INHERIT_ACE, (LPWSTR)MAKEINTRESOURCE(IDS_INHERIT_SUBKEYSONLY)},
{&GUID_NULL, 0, (LPWSTR)MAKEINTRESOURCEW(IDS_INHERIT_THISKEYONLY)},
{&GUID_NULL, CONTAINER_INHERIT_ACE, (LPWSTR)MAKEINTRESOURCEW(IDS_INHERIT_THISKEYANDSUBKEYS)},
{&GUID_NULL, INHERIT_ONLY_ACE | CONTAINER_INHERIT_ACE, (LPWSTR)MAKEINTRESOURCEW(IDS_INHERIT_SUBKEYSONLY)},
};
static HRESULT STDMETHODCALLTYPE
@ -414,14 +414,14 @@ ISecurityInformation_fnGetSecurity(struct ISecurityInformation *this,
PCRegKeySecurity obj = impl_from_ISecurityInformation(this);
LONG ErrorCode;
ErrorCode = GetNamedSecurityInfo(obj->szRegKey,
SE_REGISTRY_KEY,
RequestedInformation,
NULL,
NULL,
NULL,
NULL,
ppSecurityDescriptor);
ErrorCode = GetNamedSecurityInfoW(obj->szRegKey,
SE_REGISTRY_KEY,
RequestedInformation,
NULL,
NULL,
NULL,
NULL,
ppSecurityDescriptor);
return HRESULT_FROM_WIN32(ErrorCode);
}
@ -677,7 +677,7 @@ ISecurityObjectTypeInfo_fnGetInheritSource(struct ISecurityObjectTypeInfo *this,
PINHERITED_FROM pif, pif2;
SIZE_T pifSize;
DWORD ErrorCode, i;
LPTSTR lpBuf;
LPWSTR lpBuf;
pifSize = pACL->AceCount * sizeof(INHERITED_FROM);
pif = (PINHERITED_FROM)HeapAlloc(GetProcessHeap(),
@ -688,16 +688,16 @@ ISecurityObjectTypeInfo_fnGetInheritSource(struct ISecurityObjectTypeInfo *this,
return E_OUTOFMEMORY;
}
ErrorCode = GetInheritanceSource(obj->szRegKey,
SE_REGISTRY_KEY,
si,
(obj->ObjectInfo.dwFlags & SI_CONTAINER) != 0,
NULL,
0,
pACL,
NULL,
&RegAccessMasks,
pif);
ErrorCode = GetInheritanceSourceW(obj->szRegKey,
SE_REGISTRY_KEY,
si,
(obj->ObjectInfo.dwFlags & SI_CONTAINER) != 0,
NULL,
0,
pACL,
NULL,
&RegAccessMasks,
pif);
if (ErrorCode == ERROR_SUCCESS)
{
@ -708,7 +708,7 @@ ISecurityObjectTypeInfo_fnGetInheritSource(struct ISecurityObjectTypeInfo *this,
{
if (pif[i].AncestorName != NULL)
{
pifSize += (_tcslen(pif[i].AncestorName) + 1) * sizeof(TCHAR);
pifSize += (wcslen(pif[i].AncestorName) + 1) * sizeof(WCHAR);
}
}
@ -722,7 +722,7 @@ ISecurityObjectTypeInfo_fnGetInheritSource(struct ISecurityObjectTypeInfo *this,
}
/* copy the array and strings to the buffer */
lpBuf = (LPTSTR)((ULONG_PTR)pif2 + (pACL->AceCount * sizeof(INHERITED_FROM)));
lpBuf = (LPWSTR)((ULONG_PTR)pif2 + (pACL->AceCount * sizeof(INHERITED_FROM)));
for (i = 0;
i < pACL->AceCount;
i++)
@ -731,9 +731,9 @@ ISecurityObjectTypeInfo_fnGetInheritSource(struct ISecurityObjectTypeInfo *this,
if (pif[i].AncestorName != NULL)
{
pif2[i].AncestorName = lpBuf;
_tcscpy(lpBuf,
wcscpy(lpBuf,
pif[i].AncestorName);
lpBuf += _tcslen(pif[i].AncestorName) + 1;
lpBuf += wcslen(pif[i].AncestorName) + 1;
}
else
pif2[i].AncestorName = NULL;
@ -759,7 +759,7 @@ Cleanup:
******************************************************************************/
static PCRegKeySecurity
CRegKeySecurity_fnConstructor(LPTSTR lpRegKey,
CRegKeySecurity_fnConstructor(LPWSTR lpRegKey,
HKEY hRootKey,
SI_OBJECT_INFO *ObjectInfo,
BOOL *Btn)
@ -769,7 +769,7 @@ CRegKeySecurity_fnConstructor(LPTSTR lpRegKey,
obj = (PCRegKeySecurity)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
FIELD_OFFSET(CRegKeySecurity,
szRegKey[_tcslen(lpRegKey) + 1]));
szRegKey[wcslen(lpRegKey) + 1]));
if (obj != NULL)
{
obj->ref = 1;
@ -782,7 +782,7 @@ CRegKeySecurity_fnConstructor(LPTSTR lpRegKey,
obj->ObjectInfo = *ObjectInfo;
obj->Btn = Btn;
obj->hRootKey = hRootKey;
_tcscpy(obj->szRegKey,
wcscpy(obj->szRegKey,
lpRegKey);
}
else
@ -798,7 +798,7 @@ CRegKeySecurity_fnConstructor(LPTSTR lpRegKey,
typedef struct _CHANGE_CONTEXT
{
HKEY hKey;
LPTSTR KeyString;
LPWSTR KeyString;
} CHANGE_CONTEXT, *PCHANGE_CONTEXT;
typedef BOOL (WINAPI *PEDITSECURITY)(HWND hwndOwner,
@ -810,7 +810,7 @@ static HMODULE hAclUiDll;
BOOL
InitializeAclUiDll(VOID)
{
if (!(hAclUiDll = LoadLibrary(_T("aclui.dll"))))
if (!(hAclUiDll = LoadLibraryW(L"aclui.dll")))
{
return FALSE;
}
@ -838,13 +838,12 @@ UnloadAclUiDll(VOID)
BOOL
RegKeyEditPermissions(HWND hWndOwner,
HKEY hKey,
LPCTSTR lpMachine,
LPCTSTR lpKeyName)
LPCWSTR lpMachine,
LPCWSTR lpKeyName)
{
BOOL Result = FALSE;
LPWSTR Machine = NULL, KeyName = NULL;
LPCTSTR lphKey = NULL;
LPTSTR lpKeyPath = NULL;
LPCWSTR lphKey = NULL;
LPWSTR lpKeyPath = NULL;
PCRegKeySecurity RegKeySecurity;
SI_OBJECT_INFO ObjectInfo;
size_t lnMachine = 0, lnKeyName = 0;
@ -854,130 +853,72 @@ RegKeyEditPermissions(HWND hWndOwner,
return FALSE;
}
#ifndef UNICODE
/* aclui.dll only accepts unicode strings, convert them */
if (lpMachine != NULL)
{
lnMachine = lstrlen(lpMachine);
if (!(Machine = HeapAlloc(GetProcessHeap(),
0,
(lnMachine + 1) * sizeof(WCHAR))))
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto Cleanup;
}
if (lnMachine > 0)
{
MultiByteToWideChar(CP_ACP,
0,
lpMachine,
-1,
Machine,
lnMachine + 1);
}
else
*Machine = L'\0';
}
else
Machine = NULL;
if (lpKeyName != NULL)
{
lnKeyName = lstrlen(lpKeyName);
if (!(KeyName = HeapAlloc(GetProcessHeap(),
0,
(lnKeyName + 1) * sizeof(WCHAR))))
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto Cleanup;
}
if (lnKeyName > 0)
{
MultiByteToWideChar(CP_ACP,
0,
lpKeyName,
-1,
KeyName,
lnKeyName + 1);
}
else
*KeyName = L'\0';
}
else
KeyName = NULL;
#else
Machine = (LPWSTR)lpMachine;
KeyName = (LPWSTR)lpKeyName;
if (Machine != NULL)
lnMachine = wcslen(lpMachine);
if (KeyName != NULL)
lnKeyName = wcslen(KeyName);
#endif
if (lpKeyName != NULL)
lnKeyName = wcslen(lpKeyName);
/* build registry path */
if (lpMachine != NULL &&
(lpMachine[0] == _T('\0') ||
(lpMachine[0] == _T('.') && lpMachine[1] == _T('.'))))
(lpMachine[0] == L'\0' ||
(lpMachine[0] == L'.' && lpMachine[1] == L'.')))
{
lnMachine = 0;
}
if (hKey == HKEY_CLASSES_ROOT)
lphKey = TEXT("CLASSES_ROOT");
lphKey = L"CLASSES_ROOT";
else if (hKey == HKEY_CURRENT_USER)
lphKey = TEXT("CURRENT_USER");
lphKey = L"CURRENT_USER";
else if (hKey == HKEY_LOCAL_MACHINE)
lphKey = TEXT("MACHINE");
lphKey = L"MACHINE";
else if (hKey == HKEY_USERS)
lphKey = TEXT("USERS");
lphKey = L"USERS";
else if (hKey == HKEY_CURRENT_CONFIG)
lphKey = TEXT("CONFIG");
lphKey = L"CONFIG";
else
goto Cleanup;
lpKeyPath = HeapAlloc(GetProcessHeap(),
0,
(2 + lnMachine + 1 + _tcslen(lphKey) + 1 + lnKeyName) * sizeof(TCHAR));
(2 + lnMachine + 1 + wcslen(lphKey) + 1 + lnKeyName) * sizeof(WCHAR));
if (lpKeyPath == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto Cleanup;
}
lpKeyPath[0] = _T('\0');
lpKeyPath[0] = L'\0';
if (lnMachine != 0)
{
_tcscat(lpKeyPath,
_T("\\\\"));
_tcscat(lpKeyPath,
lpMachine);
_tcscat(lpKeyPath,
_T("\\"));
wcscat(lpKeyPath,
L"\\\\");
wcscat(lpKeyPath,
lpMachine);
wcscat(lpKeyPath,
L"\\");
}
_tcscat(lpKeyPath,
lphKey);
if (lpKeyName != NULL && lpKeyName[0] != _T('\0'))
wcscat(lpKeyPath,
lphKey);
if (lpKeyName != NULL && lpKeyName[0] != L'\0')
{
if (lpKeyName[0] != _T('\\'))
if (lpKeyName[0] != L'\\')
{
_tcscat(lpKeyPath,
_T("\\"));
wcscat(lpKeyPath,
L"\\");
}
_tcscat(lpKeyPath,
lpKeyName);
wcscat(lpKeyPath,
lpKeyName);
}
ObjectInfo.dwFlags = SI_EDIT_ALL | SI_ADVANCED | SI_CONTAINER | SI_EDIT_EFFECTIVE | SI_EDIT_PERMS |
SI_OWNER_RECURSE | SI_RESET_DACL_TREE | SI_RESET_SACL_TREE;
ObjectInfo.hInstance = hInst;
ObjectInfo.pszServerName = Machine;
ObjectInfo.pszObjectName = KeyName; /* FIXME */
ObjectInfo.pszPageTitle = KeyName; /* FIXME */
ObjectInfo.pszServerName = (LPWSTR)lpMachine;
ObjectInfo.pszObjectName = (LPWSTR)lpKeyName; /* FIXME */
ObjectInfo.pszPageTitle = (LPWSTR)lpKeyName; /* FIXME */
if (!(RegKeySecurity = CRegKeySecurity_fnConstructor(lpKeyPath,
hKey,
@ -996,22 +937,6 @@ RegKeyEditPermissions(HWND hWndOwner,
CRegKeySecurity_fnRelease(RegKeySecurity);
Cleanup:
#ifndef UNICODE
if (Machine != NULL)
{
HeapFree(GetProcessHeap(),
0,
Machine);
}
if (KeyName != NULL)
{
HeapFree(GetProcessHeap(),
0,
KeyName);
}
#endif
if (lpKeyPath != NULL)
{
HeapFree(GetProcessHeap(),

View file

@ -150,7 +150,7 @@ typedef struct _CRegKeySecurity
SI_OBJECT_INFO ObjectInfo;
BOOL *Btn;
HKEY hRootKey;
TCHAR szRegKey[1];
WCHAR szRegKey[1];
} CRegKeySecurity, *PCRegKeySecurity;
/* EOF */

View file

@ -21,7 +21,7 @@
#include <regedit.h>
const TCHAR g_szGeneralRegKey[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit");
const WCHAR g_szGeneralRegKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit";
/*
VV,VV,VV,VV,WA,WA,WA,WA,WB,WB,WB,WB,R1,R1,R1,R1
@ -47,33 +47,34 @@ DD = size of 'data' coumn
SB = status bar (1=visible / 0=hidden)
*/
typedef struct{
WINDOWPLACEMENT tPlacement;
int TreeViewSize;
int NameColumnSize;
int TypeColumnSize;
int DataColumnSize;
BOOL StatusBarVisible;
typedef struct
{
WINDOWPLACEMENT tPlacement;
int TreeViewSize;
int NameColumnSize;
int TypeColumnSize;
int DataColumnSize;
BOOL StatusBarVisible;
} RegistryBinaryConfig;
extern void LoadSettings(void)
{
HKEY hKey = NULL;
TCHAR szBuffer[MAX_PATH];
WCHAR szBuffer[MAX_PATH];
if (RegOpenKey(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
if (RegOpenKeyW(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
{
RegistryBinaryConfig tConfig;
DWORD iBufferSize = sizeof(tConfig);
if (RegQueryValueEx(hKey, L"View", NULL, NULL, (LPBYTE)&tConfig, &iBufferSize) == ERROR_SUCCESS)
if (RegQueryValueExW(hKey, L"View", NULL, NULL, (LPBYTE)&tConfig, &iBufferSize) == ERROR_SUCCESS)
{
if ( iBufferSize == sizeof(tConfig) )
if (iBufferSize == sizeof(tConfig))
{
RECT rcTemp;
/* Update status bar settings */
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|(tConfig.StatusBarVisible ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND | (tConfig.StatusBarVisible ? MF_CHECKED : MF_UNCHECKED));
ShowWindow(hStatusBar, (tConfig.StatusBarVisible ? SW_SHOW : SW_HIDE));
/* Update listview column width */
@ -95,7 +96,7 @@ extern void LoadSettings(void)
}
/* Restore key position */
if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("LastKey"), szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS)
if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, L"LastKey", szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS)
{
SelectNode(g_pChildWnd->hTreeWnd, szBuffer);
}
@ -113,14 +114,14 @@ extern void SaveSettings(void)
{
HKEY hKey = NULL;
if (RegCreateKey(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
if (RegCreateKeyW(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
{
if (RegOpenKey(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
if (RegOpenKeyW(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
{
RegistryBinaryConfig tConfig;
DWORD iBufferSize = sizeof(tConfig);
TCHAR szBuffer[MAX_PATH];
LPCTSTR keyPath, rootName;
WCHAR szBuffer[MAX_PATH];
LPCWSTR keyPath, rootName;
HKEY hRootKey;
/* Save key position */
@ -128,12 +129,12 @@ extern void SaveSettings(void)
if (keyPath)
{
rootName = get_root_key_name(hRootKey);
_sntprintf(szBuffer, COUNT_OF(szBuffer), _T("My Computer\\%s\\%s"), rootName, keyPath);
RegSetValueEx(hKey, _T("LastKey"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) _tcslen(szBuffer) * sizeof(szBuffer[0]));
_snwprintf(szBuffer, COUNT_OF(szBuffer), L"My Computer\\%s\\%s", rootName, keyPath);
RegSetValueExW(hKey, L"LastKey", 0, REG_SZ, (LPBYTE) szBuffer, (DWORD)wcslen(szBuffer) * sizeof(WCHAR));
}
/* Get statusbar settings */
tConfig.StatusBarVisible = ((GetMenuState(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND) & MF_CHECKED) ? 1 : 0 );
tConfig.StatusBarVisible = ((GetMenuState(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND) & MF_CHECKED) ? 1 : 0);
/* Get splitter position */
tConfig.TreeViewSize = g_pChildWnd->nSplitPos;
@ -148,9 +149,11 @@ extern void SaveSettings(void)
GetWindowPlacement(hFrameWnd , &tConfig.tPlacement);
/* Save all the data */
RegSetValueEx(hKey, L"View", 0, REG_BINARY, (LPBYTE)&tConfig, iBufferSize);
RegSetValueExW(hKey, L"View", 0, REG_BINARY, (LPBYTE)&tConfig, iBufferSize);
RegCloseKey(hKey);
}
}
}
/* EOF */

View file

@ -28,15 +28,15 @@ static int Image_Open = 0;
static int Image_Closed = 0;
static int Image_Root = 0;
static LPTSTR pathBuffer;
static LPWSTR pathBuffer;
#define NUM_ICONS 3
#define NUM_ICONS 3
static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKeyPath, int* pPathLen, int* pMaxLen)
static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPWSTR* pKeyPath, int* pPathLen, int* pMaxLen)
{
TVITEM item;
size_t maxLen, len;
LPTSTR newStr;
LPWSTR newStr;
item.mask = TVIF_PARAM;
item.hItem = hItem;
@ -52,7 +52,7 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe
if(!get_item_path(hwndTV, TreeView_GetParent(hwndTV, hItem), phKey, pKeyPath, pPathLen, pMaxLen)) return FALSE;
if (*pPathLen)
{
(*pKeyPath)[*pPathLen] = _T('\\');
(*pKeyPath)[*pPathLen] = L'\\';
++(*pPathLen);
}
@ -64,7 +64,7 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe
maxLen = *pMaxLen - *pPathLen;
item.cchTextMax = (int) maxLen;
if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
len = _tcslen(item.pszText);
len = wcslen(item.pszText);
if (len < maxLen - 1)
{
*pPathLen += (int) len;
@ -80,7 +80,7 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe
return TRUE;
}
LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
{
int pathLen = 0, maxLen;
@ -107,14 +107,14 @@ BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem)
}
/* Add an entry to the tree. Only give hKey for root nodes (HKEY_ constants) */
static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HKEY hKey, DWORD dwChildren)
static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPWSTR label, HKEY hKey, DWORD dwChildren)
{
TVITEM tvi;
TVINSERTSTRUCT tvins;
if (hKey)
{
if (RegQueryInfoKey(hKey, 0, 0, 0, &dwChildren, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwChildren, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
{
dwChildren = 0;
}
@ -122,7 +122,7 @@ static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HK
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
tvi.pszText = label;
tvi.cchTextMax = lstrlen(tvi.pszText);
tvi.cchTextMax = wcslen(tvi.pszText);
tvi.iImage = Image_Closed;
tvi.iSelectedImage = Image_Open;
tvi.cChildren = dwChildren;
@ -137,20 +137,20 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
{
HKEY hRoot, hKey, hSubKey;
HTREEITEM childItem;
LPCTSTR KeyPath;
LPCWSTR KeyPath;
DWORD dwCount, dwIndex, dwMaxSubKeyLen;
LPTSTR Name = NULL;
LPWSTR Name = NULL;
TVITEM tvItem;
LPTSTR pszNodes = NULL;
LPWSTR pszNodes = NULL;
BOOL bSuccess = FALSE;
LPTSTR s;
LPWSTR s;
BOOL bAddedAny;
KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
if (*KeyPath)
{
if (RegOpenKeyEx(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
{
goto done;
}
@ -160,7 +160,7 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
hKey = hRoot;
}
if (RegQueryInfoKey(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
{
goto done;
}
@ -183,12 +183,12 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
}
dwMaxSubKeyLen++; /* account for the \0 terminator */
if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR))))
if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR))))
{
goto done;
}
tvItem.cchTextMax = dwMaxSubKeyLen;
/*if (!(tvItem.pszText = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR)))) {
/*if (!(tvItem.pszText = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR)))) {
goto done;
}*/
@ -197,7 +197,7 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
DWORD dwPhysicalSize = 0;
DWORD dwActualSize = 0;
DWORD dwNewPhysicalSize;
LPTSTR pszNewNodes;
LPWSTR pszNewNodes;
DWORD dwStep = 10000;
for (childItem = TreeView_GetChild(hwndTV, hItem); childItem;
@ -209,9 +209,9 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
dwNewPhysicalSize = dwActualSize + dwMaxSubKeyLen + 1 + dwStep;
if (pszNodes)
pszNewNodes = (LPTSTR) HeapReAlloc(GetProcessHeap(), 0, pszNodes, dwNewPhysicalSize * sizeof(TCHAR));
pszNewNodes = (LPWSTR) HeapReAlloc(GetProcessHeap(), 0, pszNodes, dwNewPhysicalSize * sizeof(WCHAR));
else
pszNewNodes = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, dwNewPhysicalSize * sizeof(TCHAR));
pszNewNodes = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, dwNewPhysicalSize * sizeof(WCHAR));
if (!pszNewNodes)
goto done;
@ -226,11 +226,11 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
if (!TreeView_GetItem(hwndTV, &tvItem))
goto done;
dwActualSize += (DWORD) _tcslen(&pszNodes[dwActualSize]) + 1;
dwActualSize += (DWORD) wcslen(&pszNodes[dwActualSize]) + 1;
}
if (pszNodes)
pszNodes[dwActualSize] = '\0';
pszNodes[dwActualSize] = L'\0';
}
/* Now go through all the children in the tree, and check if any have to be removed. */
@ -253,7 +253,7 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
BOOL found;
found = FALSE;
if (RegEnumKeyEx(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS)
if (RegEnumKeyExW(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS)
{
continue;
}
@ -261,9 +261,9 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
/* Check if the node is already in there. */
if (pszNodes)
{
for (s = pszNodes; *s; s += _tcslen(s) + 1)
for (s = pszNodes; *s; s += wcslen(s) + 1)
{
if (!_tcscmp(s, Name))
if (!wcscmp(s, Name))
{
found = TRUE;
break;
@ -275,9 +275,9 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
{
/* Find the number of children of the node. */
dwSubCount = 0;
if (RegOpenKeyEx(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
if (RegOpenKeyExW(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
{
if (RegQueryInfoKey(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
if (RegQueryInfoKeyW(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
{
dwSubCount = 0;
}
@ -291,7 +291,7 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
RegCloseKey(hKey);
if (bAddedAny)
SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
SendMessageW(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
bSuccess = TRUE;
@ -311,7 +311,7 @@ BOOL RefreshTreeView(HWND hwndTV)
hSelectedItem = TreeView_GetSelection(hwndTV);
hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
SendMessage(hwndTV, WM_SETREDRAW, FALSE, 0);
SendMessageW(hwndTV, WM_SETREDRAW, FALSE, 0);
hItem = TreeView_GetChild(hwndTV, TreeView_GetRoot(hwndTV));
while (hItem)
@ -320,7 +320,7 @@ BOOL RefreshTreeView(HWND hwndTV)
hItem = TreeView_GetNextSibling(hwndTV, hItem);
}
SendMessage(hwndTV, WM_SETREDRAW, TRUE, 0);
SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
SetCursor(hcursorOld);
/* We reselect the currently selected node, this will prompt a refresh of the listview. */
@ -328,9 +328,9 @@ 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];
WCHAR buf[MAX_NEW_KEY_LEN];
HTREEITEM hNewItem = 0;
TVITEMEX item;
@ -351,7 +351,7 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name)
if ((item.state & TVIS_EXPANDEDONCE) && (item.cChildren > 0))
{
hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
SendMessageW(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
}
else
{
@ -372,7 +372,7 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name)
item.pszText = buf;
item.cchTextMax = COUNT_OF(buf);
if (!TreeView_GetItem(hwndTV, &item)) continue;
if (lstrcmp(name, item.pszText) == 0) break;
if (wcscmp(name, item.pszText) == 0) break;
}
}
if (hNewItem) (void)TreeView_SelectItem(hwndTV, hNewItem);
@ -388,7 +388,7 @@ HWND StartKeyRename(HWND hwndTV)
return TreeView_EditLabel(hwndTV, hItem);
}
static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
static BOOL InitTreeViewItems(HWND hwndTV, LPWSTR pHostName)
{
TVITEM tvi;
TVINSERTSTRUCT tvins;
@ -397,7 +397,7 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
/* Set the text of the item. */
tvi.pszText = pHostName;
tvi.cchTextMax = lstrlen(tvi.pszText);
tvi.cchTextMax = wcslen(tvi.pszText);
/* Assume the item is not a parent item, so give it an image. */
tvi.iImage = Image_Root;
tvi.iSelectedImage = Image_Root;
@ -410,16 +410,16 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
/* Add the item to the tree view control. */
if (!(hRoot = TreeView_InsertItem(hwndTV, &tvins))) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CLASSES_ROOT"), HKEY_CLASSES_ROOT, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_USER"), HKEY_CURRENT_USER, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_LOCAL_MACHINE"), HKEY_LOCAL_MACHINE, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_USERS"), HKEY_USERS, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, L"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, L"HKEY_CURRENT_USER", HKEY_CURRENT_USER, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, L"HKEY_LOCAL_MACHINE", HKEY_LOCAL_MACHINE, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, L"HKEY_USERS", HKEY_USERS, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, L"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG, 1)) return FALSE;
if (GetVersion() & 0x80000000)
{
/* Win9x specific key */
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_DYN_DATA"), HKEY_DYN_DATA, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, L"HKEY_DYN_DATA", HKEY_DYN_DATA, 1)) return FALSE;
}
/* expand and select host name */
@ -451,36 +451,36 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
}
/* Add the open file, closed file, and document bitmaps. */
hico = LoadImage(hInst,
MAKEINTRESOURCE(IDI_OPEN_FILE),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0);
hico = LoadImageW(hInst,
MAKEINTRESOURCEW(IDI_OPEN_FILE),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0);
if (hico)
{
Image_Open = ImageList_AddIcon(himl, hico);
DestroyIcon(hico);
}
hico = LoadImage(hInst,
MAKEINTRESOURCE(IDI_CLOSED_FILE),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0);
hico = LoadImageW(hInst,
MAKEINTRESOURCEW(IDI_CLOSED_FILE),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0);
if (hico)
{
Image_Closed = ImageList_AddIcon(himl, hico);
DestroyIcon(hico);
}
hico = LoadImage(hInst,
MAKEINTRESOURCE(IDI_ROOT),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0);
hico = LoadImageW(hInst,
MAKEINTRESOURCEW(IDI_ROOT),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0);
if (hico)
{
Image_Root = ImageList_AddIcon(himl, hico);
@ -504,8 +504,8 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
{
DWORD dwCount, dwIndex, dwMaxSubKeyLen;
HKEY hRoot, hNewKey, hKey;
LPCTSTR keyPath;
LPTSTR Name;
LPCWSTR keyPath;
LPWSTR Name;
LONG errCode;
HCURSOR hcursorOld;
@ -517,14 +517,14 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
}
expanding = TRUE;
hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
SendMessage(hwndTV, WM_SETREDRAW, FALSE, 0);
SendMessageW(hwndTV, WM_SETREDRAW, FALSE, 0);
keyPath = GetItemPath(hwndTV, pnmtv->itemNew.hItem, &hRoot);
if (!keyPath) goto done;
if (*keyPath)
{
errCode = RegOpenKeyEx(hRoot, keyPath, 0, KEY_READ, &hNewKey);
errCode = RegOpenKeyExW(hRoot, keyPath, 0, KEY_READ, &hNewKey);
if (errCode != ERROR_SUCCESS) goto done;
}
else
@ -532,35 +532,35 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
hNewKey = hRoot;
}
errCode = RegQueryInfoKey(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
errCode = RegQueryInfoKeyW(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
if (errCode != ERROR_SUCCESS) goto done;
dwMaxSubKeyLen++; /* account for the \0 terminator */
Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR));
Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR));
if (!Name) goto done;
for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
{
DWORD cName = dwMaxSubKeyLen, dwSubCount;
errCode = RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, 0, 0, 0, 0);
errCode = RegEnumKeyExW(hNewKey, dwIndex, Name, &cName, 0, 0, 0, 0);
if (errCode != ERROR_SUCCESS) continue;
errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey);
errCode = RegOpenKeyExW(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey);
if (errCode == ERROR_SUCCESS)
{
errCode = RegQueryInfoKey(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0);
errCode = RegQueryInfoKeyW(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0);
RegCloseKey(hKey);
}
if (errCode != ERROR_SUCCESS) dwSubCount = 0;
AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwSubCount);
}
SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM)pnmtv->itemNew.hItem);
SendMessageW(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM)pnmtv->itemNew.hItem);
RegCloseKey(hNewKey);
HeapFree(GetProcessHeap(), 0, Name);
done:
SendMessage(hwndTV, WM_SETREDRAW, TRUE, 0);
SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
SetCursor(hcursorOld);
expanding = FALSE;
@ -570,9 +570,9 @@ done:
BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
{
TCHAR szNewKeyFormat[128];
TCHAR szNewKey[128];
LPCTSTR pszKeyPath;
WCHAR szNewKeyFormat[128];
WCHAR szNewKey[128];
LPCWSTR pszKeyPath;
int iIndex = 1;
LONG nResult;
HKEY hRootKey = NULL, hKey = NULL, hNewKey = NULL;
@ -581,19 +581,19 @@ BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
HTREEITEM hNewItem;
pszKeyPath = GetItemPath(hwndTV, hItem, &hRootKey);
if (pszKeyPath[0] == TEXT('\0'))
if (pszKeyPath[0] == L'\0')
hKey = hRootKey;
else if (RegOpenKey(hRootKey, pszKeyPath, &hKey) != ERROR_SUCCESS)
else if (RegOpenKeyW(hRootKey, pszKeyPath, &hKey) != ERROR_SUCCESS)
goto done;
if (LoadString(hInst, IDS_NEW_KEY, szNewKeyFormat, COUNT_OF(szNewKeyFormat)) <= 0)
if (LoadStringW(hInst, IDS_NEW_KEY, szNewKeyFormat, COUNT_OF(szNewKeyFormat)) <= 0)
goto done;
/* Need to create a new key with a unique name */
do
{
wsprintf(szNewKey, szNewKeyFormat, iIndex++);
nResult = RegCreateKeyEx(hKey, szNewKey, 0, NULL, 0, KEY_WRITE, NULL, &hNewKey, &dwDisposition);
nResult = RegCreateKeyExW(hKey, szNewKey, 0, NULL, 0, KEY_WRITE, NULL, &hNewKey, &dwDisposition);
if (hNewKey && dwDisposition == REG_OPENED_EXISTING_KEY)
{
RegCloseKey(hNewKey);
@ -601,9 +601,9 @@ BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
}
else if (!hNewKey)
{
TCHAR sz[256];
wsprintf(sz, TEXT("Cannot create new key!\n\nError Code: %d"), nResult);
MessageBox(hFrameWnd, sz, NULL, MB_ICONERROR);
WCHAR sz[256];
wsprintf(sz, L"Cannot create new key!\n\nError Code: %d", nResult);
MessageBoxW(hFrameWnd, sz, NULL, MB_ICONERROR);
goto done;
}
}
@ -633,14 +633,14 @@ done:
* Returns the handle to the new control if successful, or NULL otherwise.
* hwndParent - handle to the control's parent window.
*/
HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, HMENU id)
HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, HMENU id)
{
RECT rcClient;
HWND hwndTV;
/* Get the dimensions of the parent window's client area, and create the tree view control. */
GetClientRect(hwndParent, &rcClient);
hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
hwndTV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_EDITLABELS,
0, 0, rcClient.right, rcClient.bottom,
hwndParent, id, hInst, NULL);
@ -659,17 +659,17 @@ void DestroyTreeView()
HeapFree(GetProcessHeap(), 0, pathBuffer);
}
BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
{
HTREEITEM hRoot, hItem;
HTREEITEM hChildItem;
TCHAR szPathPart[128];
TCHAR szBuffer[128];
LPCTSTR s;
WCHAR szPathPart[128];
WCHAR szBuffer[128];
LPCWSTR s;
TVITEM tvi;
/* Total no-good hack */
if (!_tcsnicmp(keyPath, _T("My Computer\\"), 12))
if (!_wcsnicmp(keyPath, L"My Computer\\", 12))
keyPath += 12;
hRoot = TreeView_GetRoot(hwndTV);
@ -677,24 +677,24 @@ BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
while(keyPath[0])
{
s = _tcschr(keyPath, TEXT('\\'));
lstrcpyn(szPathPart, keyPath, s ? s - keyPath + 1 : _tcslen(keyPath) + 1);
s = wcschr(keyPath, L'\\');
wcsncpy(szPathPart, keyPath, s ? s - keyPath + 1 : wcslen(keyPath) + 1);
/* Special case for root to expand root key abbreviations */
if (hItem == hRoot)
{
if (!_tcsicmp(szPathPart, TEXT("HKCR")))
_tcscpy(szPathPart, TEXT("HKEY_CLASSES_ROOT"));
else if (!_tcsicmp(szPathPart, TEXT("HKCU")))
_tcscpy(szPathPart, TEXT("HKEY_CURRENT_USER"));
else if (!_tcsicmp(szPathPart, TEXT("HKLM")))
_tcscpy(szPathPart, TEXT("HKEY_LOCAL_MACHINE"));
else if (!_tcsicmp(szPathPart, TEXT("HKU")))
_tcscpy(szPathPart, TEXT("HKEY_USERS"));
else if (!_tcsicmp(szPathPart, TEXT("HKCC")))
_tcscpy(szPathPart, TEXT("HKEY_CURRENT_CONFIG"));
else if (!_tcsicmp(szPathPart, TEXT("HKDD")))
_tcscpy(szPathPart, TEXT("HKEY_DYN_DATA"));
if (!wcsicmp(szPathPart, L"HKCR"))
wcscpy(szPathPart, L"HKEY_CLASSES_ROOT");
else if (!wcsicmp(szPathPart, L"HKCU"))
wcscpy(szPathPart, L"HKEY_CURRENT_USER");
else if (!wcsicmp(szPathPart, L"HKLM"))
wcscpy(szPathPart, L"HKEY_LOCAL_MACHINE");
else if (!wcsicmp(szPathPart, L"HKU"))
wcscpy(szPathPart, L"HKEY_USERS");
else if (!wcsicmp(szPathPart, L"HKCC"))
wcscpy(szPathPart, L"HKEY_CURRENT_CONFIG");
else if (!wcsicmp(szPathPart, L"HKDD"))
wcscpy(szPathPart, L"HKEY_DYN_DATA");
}
for (hChildItem = TreeView_GetChild(hwndTV, hItem); hChildItem;
@ -708,7 +708,7 @@ BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
(void)TreeView_GetItem(hwndTV, &tvi);
if (!_tcsicmp(szBuffer, szPathPart))
if (!wcsicmp(szBuffer, szPathPart))
break;
}
@ -721,7 +721,7 @@ BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
return FALSE;
}
keyPath = s ? s + 1 : _T("");
keyPath = s ? s + 1 : L"";
hItem = hChildItem;
}
@ -731,4 +731,4 @@ BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
return TRUE;
}
/* EOF */