From c23873e5cb9829732b5860cb20f6896b70d2faca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 3 Oct 2012 22:42:34 +0000 Subject: [PATCH] [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 --- reactos/base/applications/regedit/about.c | 8 +- reactos/base/applications/regedit/childwnd.c | 161 +++--- reactos/base/applications/regedit/edit.c | 528 +++++++++---------- reactos/base/applications/regedit/error.c | 44 +- reactos/base/applications/regedit/find.c | 276 +++++----- reactos/base/applications/regedit/framewnd.c | 355 ++++++------- reactos/base/applications/regedit/hexedit.c | 65 +-- reactos/base/applications/regedit/hexedit.h | 32 +- reactos/base/applications/regedit/listview.c | 242 +++++---- reactos/base/applications/regedit/main.c | 100 ++-- reactos/base/applications/regedit/main.h | 65 +-- reactos/base/applications/regedit/regedit.c | 182 +++---- reactos/base/applications/regedit/regedit.h | 5 +- reactos/base/applications/regedit/regproc.c | 28 +- reactos/base/applications/regedit/regproc.h | 2 - reactos/base/applications/regedit/resource.h | 1 - reactos/base/applications/regedit/security.c | 225 +++----- reactos/base/applications/regedit/security.h | 2 +- reactos/base/applications/regedit/settings.c | 47 +- reactos/base/applications/regedit/treeview.c | 212 ++++---- 20 files changed, 1239 insertions(+), 1341 deletions(-) diff --git a/reactos/base/applications/regedit/about.c b/reactos/base/applications/regedit/about.c index e8870632cc8..a503c86d1f5 100644 --- a/reactos/base/applications/regedit/about.c +++ b/reactos/base/applications/regedit/about.c @@ -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 */ diff --git a/reactos/base/applications/regedit/childwnd.c b/reactos/base/applications/regedit/childwnd.c index e927478ac23..182ce299c4c 100644 --- a/reactos/base/applications/regedit/childwnd.c +++ b/reactos/base/applications/regedit/childwnd.c @@ -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.xnSplitPos+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; } diff --git a/reactos/base/applications/regedit/edit.c b/reactos/base/applications/regedit/edit.c index 6b30846ef31..4ff2ec94844 100644 --- a/reactos/base/applications/regedit/edit.c +++ b/reactos/base/applications/regedit/edit.c @@ -27,8 +27,8 @@ typedef enum _EDIT_MODE } EDIT_MODE; -static const TCHAR* editValueName; -static TCHAR* stringValueData; +static const WCHAR* editValueName; +static WCHAR* stringValueData; static PVOID binValueData; static DWORD dwordValueData; static PCM_RESOURCE_LIST resourceValueData; @@ -39,60 +39,60 @@ static EDIT_MODE dwordEditMode = EDIT_MODE_HEX; void error(HWND hwnd, INT resId, ...) { va_list ap; - TCHAR title[256]; - TCHAR errfmt[1024]; - TCHAR errstr[1024]; + WCHAR title[256]; + WCHAR errfmt[1024]; + WCHAR errstr[1024]; HINSTANCE hInstance; hInstance = GetModuleHandle(0); - if (!LoadString(hInstance, IDS_ERROR, title, COUNT_OF(title))) - _tcscpy(title, _T("Error")); + if (!LoadStringW(hInstance, IDS_ERROR, title, COUNT_OF(title))) + wcscpy(title, L"Error"); - if (!LoadString(hInstance, resId, errfmt, COUNT_OF(errfmt))) - _tcscpy(errfmt, _T("Unknown error string!")); + if (!LoadStringW(hInstance, resId, errfmt, COUNT_OF(errfmt))) + wcscpy(errfmt, L"Unknown error string!"); va_start(ap, resId); - _vsntprintf(errstr, COUNT_OF(errstr), errfmt, ap); + _vsnwprintf(errstr, COUNT_OF(errstr), errfmt, ap); va_end(ap); - MessageBox(hwnd, errstr, title, MB_OK | MB_ICONERROR); + MessageBoxW(hwnd, errstr, title, MB_OK | MB_ICONERROR); } static void error_code_messagebox(HWND hwnd, DWORD error_code) { - TCHAR title[256]; - if (!LoadString(hInst, IDS_ERROR, title, COUNT_OF(title))) - lstrcpy(title, TEXT("Error")); + WCHAR title[256]; + if (!LoadStringW(hInst, IDS_ERROR, title, COUNT_OF(title))) + wcscpy(title, L"Error"); ErrorMessageBox(hwnd, title, error_code); } void warning(HWND hwnd, INT resId, ...) { va_list ap; - TCHAR title[256]; - TCHAR errfmt[1024]; - TCHAR errstr[1024]; + WCHAR title[256]; + WCHAR errfmt[1024]; + WCHAR errstr[1024]; HINSTANCE hInstance; hInstance = GetModuleHandle(0); - if (!LoadString(hInstance, IDS_WARNING, title, COUNT_OF(title))) - _tcscpy(title, _T("Warning")); + if (!LoadStringW(hInstance, IDS_WARNING, title, COUNT_OF(title))) + wcscpy(title, L"Warning"); - if (!LoadString(hInstance, resId, errfmt, COUNT_OF(errfmt))) - _tcscpy(errfmt, _T("Unknown error string!")); + if (!LoadStringW(hInstance, resId, errfmt, COUNT_OF(errfmt))) + wcscpy(errfmt, L"Unknown error string!"); va_start(ap, resId); - _vsntprintf(errstr, COUNT_OF(errstr), errfmt, ap); + _vsnwprintf(errstr, COUNT_OF(errstr), errfmt, ap); va_end(ap); - MessageBox(hwnd, errstr, title, MB_OK | MB_ICONSTOP); + MessageBoxW(hwnd, errstr, title, MB_OK | MB_ICONSTOP); } INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - TCHAR* valueData; + WCHAR* valueData; HWND hwndValue; int len; @@ -101,17 +101,17 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L switch(uMsg) { case WM_INITDIALOG: - if(editValueName && _tcscmp(editValueName, _T(""))) + if (editValueName && wcscmp(editValueName, L"")) { - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); + SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, editValueName); } else { - TCHAR buffer[255]; - LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer)); - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); + WCHAR buffer[255]; + LoadStringW(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer)); + SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, buffer); } - SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData); + SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, stringValueData); SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA)); return FALSE; case WM_COMMAND: @@ -124,19 +124,19 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L { if (stringValueData) { - if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR)))) + if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(WCHAR)))) { stringValueData = valueData; - if (!GetWindowText(hwndValue, stringValueData, len + 1)) + if (!GetWindowTextW(hwndValue, stringValueData, len + 1)) *stringValueData = 0; } } else { - if ((valueData = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(TCHAR)))) + if ((valueData = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)))) { stringValueData = valueData; - if (!GetWindowText(hwndValue, stringValueData, len + 1)) + if (!GetWindowTextW(hwndValue, stringValueData, len + 1)) *stringValueData = 0; } } @@ -160,7 +160,7 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - TCHAR* valueData; + WCHAR* valueData; HWND hwndValue; int len; @@ -169,17 +169,17 @@ INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPa switch(uMsg) { case WM_INITDIALOG: - if(editValueName && _tcscmp(editValueName, _T(""))) + if (editValueName && wcscmp(editValueName, L"")) { - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); + SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, editValueName); } else { - TCHAR buffer[255]; - LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer)); - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); + WCHAR buffer[255]; + LoadStringW(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer)); + SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, buffer); } - SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData); + SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, stringValueData); SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA)); return FALSE; case WM_COMMAND: @@ -192,19 +192,19 @@ INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPa { if (stringValueData) { - if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR)))) + if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(WCHAR)))) { stringValueData = valueData; - if (!GetWindowText(hwndValue, stringValueData, len + 1)) + if (!GetWindowTextW(hwndValue, stringValueData, len + 1)) *stringValueData = 0; } } else { - if ((valueData = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(TCHAR)))) + if ((valueData = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)))) { stringValueData = valueData; - if (!GetWindowText(hwndValue, stringValueData, len + 1)) + if (!GetWindowTextW(hwndValue, stringValueData, len + 1)) *stringValueData = 0; } } @@ -271,8 +271,8 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP { WNDPROC oldproc; HWND hwndValue; - TCHAR ValueString[32]; - LPTSTR Remainder; + WCHAR ValueString[32]; + LPWSTR Remainder; DWORD Base; DWORD Value = 0; @@ -289,19 +289,19 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP SetWindowLongPtr(hwndValue, GWL_USERDATA, (DWORD_PTR)oldproc); SetWindowLongPtr(hwndValue, GWL_WNDPROC, (DWORD_PTR)DwordEditSubclassProc); - if(editValueName && _tcscmp(editValueName, _T(""))) + if (editValueName && wcscmp(editValueName, L"")) { - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); + SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, editValueName); } else { - TCHAR buffer[255]; - LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer)); - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); + WCHAR buffer[255]; + LoadStringW(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer)); + SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, buffer); } CheckRadioButton (hwndDlg, IDC_FORMAT_HEX, IDC_FORMAT_DEC, IDC_FORMAT_HEX); - _stprintf (ValueString, _T("%lx"), dwordValueData); - SetDlgItemText(hwndDlg, IDC_VALUE_DATA, ValueString); + swprintf(ValueString, L"%lx", dwordValueData); + SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, ValueString); SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA)); return FALSE; @@ -316,14 +316,14 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP { if (GetWindowTextLength(hwndValue)) { - if (GetWindowText(hwndValue, ValueString, 32)) + if (GetWindowTextW(hwndValue, ValueString, 32)) { - Value = _tcstoul (ValueString, &Remainder, 10); + Value = wcstoul (ValueString, &Remainder, 10); } } } - _stprintf (ValueString, _T("%lx"), Value); - SetDlgItemText(hwndDlg, IDC_VALUE_DATA, ValueString); + swprintf(ValueString, L"%lx", Value); + SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, ValueString); return TRUE; } break; @@ -336,14 +336,14 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP { if (GetWindowTextLength(hwndValue)) { - if (GetWindowText(hwndValue, ValueString, 32)) + if (GetWindowTextW(hwndValue, ValueString, 32)) { - Value = _tcstoul (ValueString, &Remainder, 16); + Value = wcstoul (ValueString, &Remainder, 16); } } } - _stprintf (ValueString, _T("%lu"), Value); - SetDlgItemText(hwndDlg, IDC_VALUE_DATA, ValueString); + swprintf(ValueString, L"%lu", Value); + SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, ValueString); return TRUE; } break; @@ -353,14 +353,14 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP { if (GetWindowTextLength(hwndValue)) { - if (!GetWindowText(hwndValue, ValueString, 32)) + if (!GetWindowTextW(hwndValue, ValueString, 32)) { EndDialog(hwndDlg, IDCANCEL); return TRUE; } Base = (dwordEditMode == EDIT_MODE_HEX) ? 16 : 10; - dwordValueData = _tcstoul (ValueString, &Remainder, Base); + dwordValueData = wcstoul (ValueString, &Remainder, Base); } else { @@ -390,20 +390,20 @@ INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L switch(uMsg) { case WM_INITDIALOG: - if(editValueName && _tcscmp(editValueName, _T(""))) + if (editValueName && wcscmp(editValueName, L"")) { - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); + SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, editValueName); } else { - TCHAR buffer[255]; - LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer)); - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer); + WCHAR buffer[255]; + LoadStringW(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer)); + SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, buffer); } hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA); HexEdit_LoadBuffer(hwndValue, binValueData, valueDataLen); /* reset the hex edit control's font */ - SendMessage(hwndValue, WM_SETFONT, 0, 0); + SendMessageW(hwndValue, WM_SETFONT, 0, 0); SetFocus(hwndValue); return FALSE; case WM_COMMAND: @@ -433,9 +433,9 @@ INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L static BOOL CreateResourceColumns(HWND hwnd) { - TCHAR szText[80]; + WCHAR szText[80]; RECT rc; - LV_COLUMN lvC; + LVCOLUMN lvC; HWND hwndLV; INT width; @@ -451,13 +451,13 @@ static BOOL CreateResourceColumns(HWND hwnd) /* Load the column labels from the resource file. */ lvC.iSubItem = 0; lvC.cx = (rc.right - rc.left) / 2; - LoadString(hInst, IDS_DMA_CHANNEL, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_DMA_CHANNEL, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1) return FALSE; lvC.iSubItem = 1; lvC.cx = (rc.right - rc.left) - lvC.cx; - LoadString(hInst, IDS_DMA_PORT, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_DMA_PORT, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1) return FALSE; @@ -471,23 +471,23 @@ static BOOL CreateResourceColumns(HWND hwnd) /* Load the column labels from the resource file. */ lvC.iSubItem = 0; lvC.cx = width; - LoadString(hInst, IDS_INTERRUPT_VECTOR, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_INTERRUPT_VECTOR, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1) return FALSE; lvC.iSubItem = 1; - LoadString(hInst, IDS_INTERRUPT_LEVEL, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_INTERRUPT_LEVEL, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1) return FALSE; lvC.iSubItem = 2; - LoadString(hInst, IDS_INTERRUPT_AFFINITY, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_INTERRUPT_AFFINITY, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 2, &lvC) == -1) return FALSE; lvC.iSubItem = 3; lvC.cx = (rc.right - rc.left) - 3 * width; - LoadString(hInst, IDS_INTERRUPT_TYPE, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_INTERRUPT_TYPE, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 3, &lvC) == -1) return FALSE; @@ -501,18 +501,18 @@ static BOOL CreateResourceColumns(HWND hwnd) /* Load the column labels from the resource file. */ lvC.iSubItem = 0; lvC.cx = width; - LoadString(hInst, IDS_MEMORY_ADDRESS, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_MEMORY_ADDRESS, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1) return FALSE; lvC.iSubItem = 1; - LoadString(hInst, IDS_MEMORY_LENGTH, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_MEMORY_LENGTH, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1) return FALSE; lvC.iSubItem = 2; lvC.cx = (rc.right - rc.left) - 2 * width; - LoadString(hInst, IDS_MEMORY_ACCESS, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_MEMORY_ACCESS, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 2, &lvC) == -1) return FALSE; @@ -526,18 +526,18 @@ static BOOL CreateResourceColumns(HWND hwnd) /* Load the column labels from the resource file. */ lvC.iSubItem = 0; lvC.cx = width; - LoadString(hInst, IDS_PORT_ADDRESS, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_PORT_ADDRESS, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1) return FALSE; lvC.iSubItem = 1; - LoadString(hInst, IDS_PORT_LENGTH, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_PORT_LENGTH, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1) return FALSE; lvC.iSubItem = 2; lvC.cx = (rc.right - rc.left) - 2 * width; - LoadString(hInst, IDS_PORT_ACCESS, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_PORT_ACCESS, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 2, &lvC) == -1) return FALSE; @@ -550,18 +550,18 @@ static BOOL CreateResourceColumns(HWND hwnd) /* Load the column labels from the resource file. */ lvC.iSubItem = 0; lvC.cx = width; - LoadString(hInst, IDS_SPECIFIC_RESERVED1, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_SPECIFIC_RESERVED1, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1) return FALSE; lvC.iSubItem = 1; - LoadString(hInst, IDS_SPECIFIC_RESERVED2, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_SPECIFIC_RESERVED2, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1) return FALSE; lvC.iSubItem = 2; lvC.cx = (rc.right - rc.left) - 2 * width; - LoadString(hInst, IDS_SPECIFIC_DATASIZE, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_SPECIFIC_DATASIZE, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hwndLV, 2, &lvC) == -1) return FALSE; @@ -570,88 +570,88 @@ static BOOL CreateResourceColumns(HWND hwnd) static VOID GetInterfaceType(INTERFACE_TYPE InterfaceType, - LPTSTR pBuffer, + LPWSTR pBuffer, DWORD dwLength) { -// LPTSTR lpInterfaceType; +// LPWSTR lpInterfaceType; switch (InterfaceType) { case InterfaceTypeUndefined: - LoadString(hInst, IDS_BUS_UNDEFINED, pBuffer, dwLength); -// lpInterfaceType = _T("Undefined"); + LoadStringW(hInst, IDS_BUS_UNDEFINED, pBuffer, dwLength); +// lpInterfaceType = L"Undefined"; break; case Internal: - LoadString(hInst, IDS_BUS_INTERNAL, pBuffer, dwLength); -// lpInterfaceType = _T("Internal"); + LoadStringW(hInst, IDS_BUS_INTERNAL, pBuffer, dwLength); +// lpInterfaceType = L"Internal"; break; case Isa: - LoadString(hInst, IDS_BUS_ISA, pBuffer, dwLength); -// lpInterfaceType = _T("Isa"); + LoadStringW(hInst, IDS_BUS_ISA, pBuffer, dwLength); +// lpInterfaceType = L"Isa"; break; case Eisa: - LoadString(hInst, IDS_BUS_EISA, pBuffer, dwLength); -// lpInterfaceType = _T("Eisa"); + LoadStringW(hInst, IDS_BUS_EISA, pBuffer, dwLength); +// lpInterfaceType = L"Eisa"; break; case MicroChannel: - LoadString(hInst, IDS_BUS_MICROCHANNEL, pBuffer, dwLength); -// lpInterfaceType = _T("MicroChannel"); + LoadStringW(hInst, IDS_BUS_MICROCHANNEL, pBuffer, dwLength); +// lpInterfaceType = L"MicroChannel"; break; case TurboChannel: - LoadString(hInst, IDS_BUS_TURBOCHANNEL, pBuffer, dwLength); -// lpInterfaceType = _T("TurboChannel"); + LoadStringW(hInst, IDS_BUS_TURBOCHANNEL, pBuffer, dwLength); +// lpInterfaceType = L"TurboChannel"; break; case PCIBus: - LoadString(hInst, IDS_BUS_PCIBUS, pBuffer, dwLength); -// lpInterfaceType = _T("PCIBus"); + LoadStringW(hInst, IDS_BUS_PCIBUS, pBuffer, dwLength); +// lpInterfaceType = L"PCIBus"; break; case VMEBus: - LoadString(hInst, IDS_BUS_VMEBUS, pBuffer, dwLength); -// lpInterfaceType = _T("VMEBus"); + LoadStringW(hInst, IDS_BUS_VMEBUS, pBuffer, dwLength); +// lpInterfaceType = L"VMEBus"; break; case NuBus: - LoadString(hInst, IDS_BUS_NUBUS, pBuffer, dwLength); -// lpInterfaceType = _T("NuBus"); + LoadStringW(hInst, IDS_BUS_NUBUS, pBuffer, dwLength); +// lpInterfaceType = L"NuBus"; break; case PCMCIABus: - LoadString(hInst, IDS_BUS_PCMCIABUS, pBuffer, dwLength); -// lpInterfaceType = _T("PCMCIABus"); + LoadStringW(hInst, IDS_BUS_PCMCIABUS, pBuffer, dwLength); +// lpInterfaceType = L"PCMCIABus"; break; case CBus: - LoadString(hInst, IDS_BUS_CBUS, pBuffer, dwLength); -// lpInterfaceType = _T("CBus"); + LoadStringW(hInst, IDS_BUS_CBUS, pBuffer, dwLength); +// lpInterfaceType = L"CBus"; break; case MPIBus: - LoadString(hInst, IDS_BUS_MPIBUS, pBuffer, dwLength); -// lpInterfaceType = _T("MPIBus"); + LoadStringW(hInst, IDS_BUS_MPIBUS, pBuffer, dwLength); +// lpInterfaceType = L"MPIBus"; break; case MPSABus: - LoadString(hInst, IDS_BUS_MPSABUS, pBuffer, dwLength); -// lpInterfaceType = _T("MPSABus"); + LoadStringW(hInst, IDS_BUS_MPSABUS, pBuffer, dwLength); +// lpInterfaceType = L"MPSABus"; break; case ProcessorInternal: - LoadString(hInst, IDS_BUS_PROCESSORINTERNAL, pBuffer, dwLength); -// lpInterfaceType = _T("ProcessorInternal"); + LoadStringW(hInst, IDS_BUS_PROCESSORINTERNAL, pBuffer, dwLength); +// lpInterfaceType = L"ProcessorInternal"; break; case InternalPowerBus: - LoadString(hInst, IDS_BUS_INTERNALPOWERBUS, pBuffer, dwLength); -// lpInterfaceType = _T("InternalPowerBus"); + LoadStringW(hInst, IDS_BUS_INTERNALPOWERBUS, pBuffer, dwLength); +// lpInterfaceType = L"InternalPowerBus"; break; case PNPISABus: - LoadString(hInst, IDS_BUS_PNPISABUS, pBuffer, dwLength); -// lpInterfaceType = _T("PNPISABus"); + LoadStringW(hInst, IDS_BUS_PNPISABUS, pBuffer, dwLength); +// lpInterfaceType = L"PNPISABus"; break; case PNPBus: - LoadString(hInst, IDS_BUS_PNPBUS, pBuffer, dwLength); -// lpInterfaceType = _T("PNPBus"); + LoadStringW(hInst, IDS_BUS_PNPBUS, pBuffer, dwLength); +// lpInterfaceType = L"PNPBus"; break; default: - LoadString(hInst, IDS_BUS_UNKNOWNTYPE, pBuffer, dwLength); -// lpInterfaceType = _T("Unknown interface type"); + LoadStringW(hInst, IDS_BUS_UNKNOWNTYPE, pBuffer, dwLength); +// lpInterfaceType = L"Unknown interface type"; break; } -// _tcscpy(pBuffer, lpInterfaceType); +// wcscpy(pBuffer, lpInterfaceType); } @@ -664,7 +664,7 @@ ParseResources(HWND hwnd) ULONG i; HWND hwndLV; - TCHAR buffer[80]; + WCHAR buffer[80]; LVITEM item; INT iItem; @@ -673,7 +673,7 @@ ParseResources(HWND hwnd) /* Interface type */ GetInterfaceType(pFullDescriptor->InterfaceType, buffer, 80); - SetDlgItemText(hwnd, IDC_INTERFACETYPE, buffer); + SetDlgItemTextW(hwnd, IDC_INTERFACETYPE, buffer); /* Busnumber */ SetDlgItemInt(hwnd, IDC_BUSNUMBER, (UINT)pFullDescriptor->BusNumber, FALSE); @@ -694,9 +694,9 @@ ParseResources(HWND hwnd) hwndLV = GetDlgItem(hwnd, IDC_PORT_LIST); #ifdef _M_AMD64 - wsprintf(buffer, _T("0x%16I64x"), pDescriptor->u.Port.Start.QuadPart); + wsprintf(buffer, L"0x%16I64x", pDescriptor->u.Port.Start.QuadPart); #else - wsprintf(buffer, _T("0x%08lx"), pDescriptor->u.Port.Start.u.LowPart); + wsprintf(buffer, L"0x%08lx", pDescriptor->u.Port.Start.u.LowPart); #endif item.mask = LVIF_TEXT | LVIF_PARAM; @@ -705,19 +705,19 @@ ParseResources(HWND hwnd) item.state = 0; item.stateMask = 0; item.pszText = buffer; - item.cchTextMax = (int)_tcslen(item.pszText); + item.cchTextMax = (int)wcslen(item.pszText); item.lParam = (LPARAM)pDescriptor; iItem = ListView_InsertItem(hwndLV, &item); if (iItem != -1) { - wsprintf(buffer, _T("0x%lx"), pDescriptor->u.Port.Length); + wsprintf(buffer, L"0x%lx", pDescriptor->u.Port.Length); ListView_SetItemText(hwndLV, iItem, 1, buffer); if (pDescriptor->Flags & CM_RESOURCE_PORT_IO) - LoadString(hInst, IDS_PORT_PORT_IO, buffer, COUNT_OF(buffer)); + LoadStringW(hInst, IDS_PORT_PORT_IO, buffer, COUNT_OF(buffer)); else - LoadString(hInst, IDS_PORT_MEMORY_IO, buffer, COUNT_OF(buffer)); + LoadStringW(hInst, IDS_PORT_MEMORY_IO, buffer, COUNT_OF(buffer)); ListView_SetItemText(hwndLV, iItem, 2, buffer); } break; @@ -725,7 +725,7 @@ ParseResources(HWND hwnd) case CmResourceTypeInterrupt: hwndLV = GetDlgItem(hwnd, IDC_IRQ_LIST); - wsprintf(buffer, _T("%lu"), pDescriptor->u.Interrupt.Vector); + wsprintf(buffer, L"%lu", pDescriptor->u.Interrupt.Vector); item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = 1000; @@ -733,22 +733,22 @@ ParseResources(HWND hwnd) item.state = 0; item.stateMask = 0; item.pszText = buffer; - item.cchTextMax = (int)_tcslen(item.pszText); + item.cchTextMax = (int)wcslen(item.pszText); item.lParam = (LPARAM)pDescriptor; iItem = ListView_InsertItem(hwndLV, &item); if (iItem != -1) { - wsprintf(buffer, _T("%lu"), pDescriptor->u.Interrupt.Level); + wsprintf(buffer, L"%lu", pDescriptor->u.Interrupt.Level); ListView_SetItemText(hwndLV, iItem, 1, buffer); - wsprintf(buffer, _T("0x%08lx"), pDescriptor->u.Interrupt.Affinity); + wsprintf(buffer, L"0x%08lx", pDescriptor->u.Interrupt.Affinity); ListView_SetItemText(hwndLV, iItem, 2, buffer); if (pDescriptor->Flags & CM_RESOURCE_INTERRUPT_LATCHED) - LoadString(hInst, IDS_INTERRUPT_EDGE_SENSITIVE, buffer, COUNT_OF(buffer)); + LoadStringW(hInst, IDS_INTERRUPT_EDGE_SENSITIVE, buffer, COUNT_OF(buffer)); else - LoadString(hInst, IDS_INTERRUPT_LEVEL_SENSITIVE, buffer, COUNT_OF(buffer)); + LoadStringW(hInst, IDS_INTERRUPT_LEVEL_SENSITIVE, buffer, COUNT_OF(buffer)); ListView_SetItemText(hwndLV, iItem, 3, buffer); } @@ -758,9 +758,9 @@ ParseResources(HWND hwnd) hwndLV = GetDlgItem(hwnd, IDC_MEMORY_LIST); #ifdef _M_AMD64 - wsprintf(buffer, _T("0x%16I64x"), pDescriptor->u.Memory.Start.QuadPart); + wsprintf(buffer, L"0x%16I64x", pDescriptor->u.Memory.Start.QuadPart); #else - wsprintf(buffer, _T("0x%08lx"), pDescriptor->u.Memory.Start.u.LowPart); + wsprintf(buffer, L"0x%08lx", pDescriptor->u.Memory.Start.u.LowPart); #endif item.mask = LVIF_TEXT | LVIF_PARAM; @@ -769,27 +769,27 @@ ParseResources(HWND hwnd) item.state = 0; item.stateMask = 0; item.pszText = buffer; - item.cchTextMax = (int)_tcslen(item.pszText); + item.cchTextMax = (int)wcslen(item.pszText); item.lParam = (LPARAM)pDescriptor; iItem = ListView_InsertItem(hwndLV, &item); if (iItem != -1) { - wsprintf(buffer, _T("0x%lx"), pDescriptor->u.Memory.Length); + wsprintf(buffer, L"0x%lx", pDescriptor->u.Memory.Length); ListView_SetItemText(hwndLV, iItem, 1, buffer); switch (pDescriptor->Flags & (CM_RESOURCE_MEMORY_READ_ONLY | CM_RESOURCE_MEMORY_WRITE_ONLY)) { case CM_RESOURCE_MEMORY_READ_ONLY: - LoadString(hInst, IDS_MEMORY_READ_ONLY, buffer, COUNT_OF(buffer)); + LoadStringW(hInst, IDS_MEMORY_READ_ONLY, buffer, COUNT_OF(buffer)); break; case CM_RESOURCE_MEMORY_WRITE_ONLY: - LoadString(hInst, IDS_MEMORY_WRITE_ONLY, buffer, COUNT_OF(buffer)); + LoadStringW(hInst, IDS_MEMORY_WRITE_ONLY, buffer, COUNT_OF(buffer)); break; default: - LoadString(hInst, IDS_MEMORY_READ_WRITE, buffer, COUNT_OF(buffer)); + LoadStringW(hInst, IDS_MEMORY_READ_WRITE, buffer, COUNT_OF(buffer)); break; } @@ -800,7 +800,7 @@ ParseResources(HWND hwnd) case CmResourceTypeDma: hwndLV = GetDlgItem(hwnd, IDC_DMA_LIST); - wsprintf(buffer, _T("%lu"), pDescriptor->u.Dma.Channel); + wsprintf(buffer, L"%lu", pDescriptor->u.Dma.Channel); item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = 1000; @@ -808,13 +808,13 @@ ParseResources(HWND hwnd) item.state = 0; item.stateMask = 0; item.pszText = buffer; - item.cchTextMax = (int)_tcslen(item.pszText); + item.cchTextMax = (int)wcslen(item.pszText); item.lParam = (LPARAM)pDescriptor; iItem = ListView_InsertItem(hwndLV, &item); if (iItem != -1) { - wsprintf(buffer, _T("%lu"), pDescriptor->u.Dma.Port); + wsprintf(buffer, L"%lu", pDescriptor->u.Dma.Port); ListView_SetItemText(hwndLV, iItem, 1, buffer); } break; @@ -822,7 +822,7 @@ ParseResources(HWND hwnd) case CmResourceTypeDeviceSpecific: hwndLV = GetDlgItem(hwnd, IDC_DEVICE_LIST); - wsprintf(buffer, _T("0x%08lx"), pDescriptor->u.DeviceSpecificData.Reserved1); + wsprintf(buffer, L"0x%08lx", pDescriptor->u.DeviceSpecificData.Reserved1); item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = 1000; @@ -830,16 +830,16 @@ ParseResources(HWND hwnd) item.state = 0; item.stateMask = 0; item.pszText = buffer; - item.cchTextMax = (int)_tcslen(item.pszText); + item.cchTextMax = (int)wcslen(item.pszText); item.lParam = (LPARAM)pDescriptor; iItem = ListView_InsertItem(hwndLV, &item); if (iItem != -1) { - wsprintf(buffer, _T("0x%08lx"), pDescriptor->u.DeviceSpecificData.Reserved2); + wsprintf(buffer, L"0x%08lx", pDescriptor->u.DeviceSpecificData.Reserved2); ListView_SetItemText(hwndLV, iItem, 1, buffer); - wsprintf(buffer, _T("0x%lx"), pDescriptor->u.DeviceSpecificData.DataSize); + wsprintf(buffer, L"0x%lx", pDescriptor->u.DeviceSpecificData.DataSize); ListView_SetItemText(hwndLV, iItem, 2, buffer); } break; @@ -935,9 +935,9 @@ static INT_PTR CALLBACK modify_resource_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM static BOOL CreateResourceListColumns(HWND hWndListView) { - TCHAR szText[80]; + WCHAR szText[80]; RECT rc; - LV_COLUMN lvC; + LVCOLUMN lvC; ListView_SetExtendedListViewStyle(hWndListView, LVS_EX_FULLROWSELECT); @@ -951,13 +951,13 @@ static BOOL CreateResourceListColumns(HWND hWndListView) /* Load the column labels from the resource file. */ lvC.iSubItem = 0; lvC.cx = (rc.right - rc.left) / 2; - LoadString(hInst, IDS_BUSNUMBER, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_BUSNUMBER, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hWndListView, 0, &lvC) == -1) return FALSE; lvC.iSubItem = 1; lvC.cx = (rc.right - rc.left) - lvC.cx; - LoadString(hInst, IDS_INTERFACE, szText, COUNT_OF(szText)); + LoadStringW(hInst, IDS_INTERFACE, szText, COUNT_OF(szText)); if (ListView_InsertColumn(hWndListView, 1, &lvC) == -1) return FALSE; @@ -967,7 +967,7 @@ static BOOL CreateResourceListColumns(HWND hWndListView) static VOID AddFullResourcesToList(HWND hwnd) { PCM_FULL_RESOURCE_DESCRIPTOR pFullDescriptor; - TCHAR buffer[80]; + WCHAR buffer[80]; LVITEM item; ULONG i; INT iItem; @@ -976,7 +976,7 @@ static VOID AddFullResourcesToList(HWND hwnd) { pFullDescriptor = &resourceValueData->List[i]; - wsprintf(buffer, _T("%lu"), pFullDescriptor->BusNumber); + wsprintf(buffer, L"%lu", pFullDescriptor->BusNumber); item.mask = LVIF_TEXT; item.iItem = i; @@ -984,7 +984,7 @@ static VOID AddFullResourcesToList(HWND hwnd) item.state = 0; item.stateMask = 0; item.pszText = buffer; - item.cchTextMax = (int)_tcslen(item.pszText); + item.cchTextMax = (int)wcslen(item.pszText); iItem = ListView_InsertItem(hwnd, &item); if (iItem != -1) @@ -1014,7 +1014,7 @@ OnResourceListNotify(HWND hwndDlg, NMHDR *phdr) if (lpnmlv->iItem != -1) { fullResourceIndex = lpnmlv->iItem; - DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_RESOURCE), hwndDlg, modify_resource_dlgproc); + DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_RESOURCE), hwndDlg, modify_resource_dlgproc); } break; } @@ -1044,7 +1044,7 @@ static INT_PTR CALLBACK modify_resource_list_dlgproc(HWND hwndDlg, UINT uMsg, WP { case IDC_SHOW_RESOURCE: if (fullResourceIndex != -1) - DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_RESOURCE), hwndDlg, modify_resource_dlgproc); + DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_RESOURCE), hwndDlg, modify_resource_dlgproc); break; case IDOK: EndDialog(hwndDlg, IDOK); @@ -1058,7 +1058,7 @@ static INT_PTR CALLBACK modify_resource_list_dlgproc(HWND hwndDlg, UINT uMsg, WP } -BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) +BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin) { DWORD type; LONG lRet; @@ -1069,8 +1069,8 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) editValueName = valueName; - lRet = RegQueryValueEx(hKey, valueName, 0, &type, 0, &valueDataLen); - if (lRet != ERROR_SUCCESS && (!_tcscmp(valueName, _T("")) || valueName == NULL)) + lRet = RegQueryValueExW(hKey, valueName, 0, &type, 0, &valueDataLen); + if (lRet != ERROR_SUCCESS && (!wcscmp(valueName, L"") || valueName == NULL)) { lRet = ERROR_SUCCESS; /* Allow editing of (Default) values which don't exist */ type = REG_SZ; @@ -1094,7 +1094,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen); goto done; } - lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)stringValueData, &valueDataLen); + lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)stringValueData, &valueDataLen); if (lRet != ERROR_SUCCESS) { error(hwnd, IDS_BAD_VALUE, valueName); @@ -1106,15 +1106,15 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) stringValueData = NULL; } - if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) + if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) { if (stringValueData) { - lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)stringValueData, (DWORD) (_tcslen(stringValueData) + 1) * sizeof(TCHAR)); + lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)stringValueData, (DWORD) (wcslen(stringValueData) + 1) * sizeof(WCHAR)); } else { - lRet = RegSetValueEx(hKey, valueName, 0, type, NULL, 0); + lRet = RegSetValueExW(hKey, valueName, 0, type, NULL, 0); } if (lRet == ERROR_SUCCESS) result = TRUE; @@ -1125,14 +1125,14 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) if (valueDataLen > 0) { size_t llen, listlen, nl_len; - LPTSTR src, lines = NULL; + LPWSTR src, lines = NULL; - if (!(stringValueData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, valueDataLen + sizeof(TCHAR)))) + if (!(stringValueData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, valueDataLen + sizeof(WCHAR)))) { error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen); goto done; } - lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)stringValueData, &valueDataLen); + lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)stringValueData, &valueDataLen); if (lRet != ERROR_SUCCESS) { error(hwnd, IDS_BAD_VALUE, valueName); @@ -1141,18 +1141,18 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) /* convert \0 to \r\n */ src = stringValueData; - nl_len = _tcslen(_T("\r\n")) * sizeof(TCHAR); - listlen = sizeof(TCHAR); - lines = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, listlen + sizeof(TCHAR)); - while(*src != _T('\0')) + nl_len = wcslen(L"\r\n") * sizeof(WCHAR); + listlen = sizeof(WCHAR); + lines = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, listlen + sizeof(WCHAR)); + while(*src != L'\0') { - llen = _tcslen(src); + llen = wcslen(src); if(llen == 0) break; - listlen += (llen * sizeof(TCHAR)) + nl_len; + listlen += (llen * sizeof(WCHAR)) + nl_len; lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, listlen); - _tcscat(lines, src); - _tcscat(lines, _T("\r\n")); + wcscat(lines, src); + wcscat(lines, L"\r\n"); src += llen + 1; } HeapFree(GetProcessHeap(), 0, stringValueData); @@ -1163,23 +1163,23 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) stringValueData = NULL; } - if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_MULTI_STRING), hwnd, modify_multi_string_dlgproc) == IDOK) + if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_MULTI_STRING), hwnd, modify_multi_string_dlgproc) == IDOK) { if (stringValueData) { /* convert \r\n to \0 */ BOOL EmptyLines = FALSE; - LPTSTR src, lines, nl; + LPWSTR src, lines, nl; size_t linechars, buflen, c_nl, dest; src = stringValueData; - buflen = sizeof(TCHAR); - lines = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen + sizeof(TCHAR)); - c_nl = _tcslen(_T("\r\n")); + buflen = sizeof(WCHAR); + lines = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen + sizeof(WCHAR)); + c_nl = wcslen(L"\r\n"); dest = 0; - while(*src != _T('\0')) + while(*src != L'\0') { - if((nl = _tcsstr(src, _T("\r\n")))) + if((nl = wcsstr(src, L"\r\n"))) { linechars = nl - src; if(nl == src) @@ -1191,15 +1191,15 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) } else { - linechars = _tcslen(src); + linechars = wcslen(src); } if(linechars > 0) { - buflen += ((linechars + 1) * sizeof(TCHAR)); + buflen += ((linechars + 1) * sizeof(WCHAR)); lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, buflen); - memcpy((lines + dest), src, linechars * sizeof(TCHAR)); + memcpy((lines + dest), src, linechars * sizeof(WCHAR)); dest += linechars; - lines[dest++] = _T('\0'); + lines[dest++] = L'\0'; } else { @@ -1207,19 +1207,19 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) } src += linechars + (nl != NULL ? c_nl : 0); } - lines[++dest] = _T('\0'); + lines[++dest] = L'\0'; if(EmptyLines) { warning(hwnd, IDS_MULTI_SZ_EMPTY_STRING); } - lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)lines, (DWORD) buflen); + lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)lines, (DWORD) buflen); HeapFree(GetProcessHeap(), 0, lines); } else { - lRet = RegSetValueEx(hKey, valueName, 0, type, NULL, 0); + lRet = RegSetValueExW(hKey, valueName, 0, type, NULL, 0); } if (lRet == ERROR_SUCCESS) result = TRUE; @@ -1227,16 +1227,16 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) } else if (EditBin == FALSE && type == REG_DWORD) { - lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)&dwordValueData, &valueDataLen); + lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)&dwordValueData, &valueDataLen); if (lRet != ERROR_SUCCESS) { error(hwnd, IDS_BAD_VALUE, valueName); goto done; } - if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_DWORD), hwnd, modify_dword_dlgproc) == IDOK) + if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_DWORD), hwnd, modify_dword_dlgproc) == IDOK) { - lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)&dwordValueData, sizeof(DWORD)); + lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)&dwordValueData, sizeof(DWORD)); if (lRet == ERROR_SUCCESS) result = TRUE; } @@ -1252,7 +1252,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) goto done; } - lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)resourceValueData, &valueDataLen); + lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)resourceValueData, &valueDataLen); if (lRet != ERROR_SUCCESS) { error(hwnd, IDS_BAD_VALUE, valueName); @@ -1264,30 +1264,12 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) resourceValueData = NULL; } - if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_RESOURCE_LIST), hwnd, modify_resource_list_dlgproc) == IDOK) + if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_RESOURCE_LIST), hwnd, modify_resource_list_dlgproc) == IDOK) { } } else if (EditBin == TRUE || type == REG_NONE || type == REG_BINARY) { -#ifndef UNICODE - LPWSTR u_valuename; - int len_vname = lstrlen(valueName); - - if(len_vname > 0) - { - if(!(u_valuename = HeapAlloc(GetProcessHeap(), 0, (len_vname + 1) * sizeof(WCHAR)))) - { - error(hwnd, IDS_TOO_BIG_VALUE, len_vname); - goto done; - } - /* convert the ansi value name to an unicode string */ - MultiByteToWideChar(CP_ACP, 0, valueName, -1, u_valuename, len_vname + 1); - valueDataLen *= sizeof(WCHAR); - } - else - u_valuename = L""; -#endif if(valueDataLen > 0) { if(!(binValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen + 1))) @@ -1296,21 +1278,12 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) goto done; } - /* force to use the unicode version, so editing strings in binary mode is correct */ - lRet = RegQueryValueExW(hKey, -#ifndef UNICODE - u_valuename, -#else - valueName, -#endif + /* Use the unicode version, so editing strings in binary mode is correct */ + lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)binValueData, &valueDataLen); if (lRet != ERROR_SUCCESS) { HeapFree(GetProcessHeap(), 0, binValueData); -#ifndef UNICODE - if(len_vname > 0) - HeapFree(GetProcessHeap(), 0, u_valuename); -#endif error(hwnd, IDS_BAD_VALUE, valueName); goto done; } @@ -1320,25 +1293,16 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin) binValueData = NULL; } - if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_BIN_DATA), hwnd, modify_binary_dlgproc) == IDOK) + if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_BIN_DATA), hwnd, modify_binary_dlgproc) == IDOK) { - /* force to use the unicode version, so editing strings in binary mode is correct */ - lRet = RegSetValueExW(hKey, -#ifndef UNICODE - u_valuename, -#else - valueName, -#endif + /* Use the unicode version, so editing strings in binary mode is correct */ + lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)binValueData, valueDataLen); if (lRet == ERROR_SUCCESS) result = TRUE; } if(binValueData != NULL) HeapFree(GetProcessHeap(), 0, binValueData); -#ifndef UNICODE - if(len_vname > 0) - HeapFree(GetProcessHeap(), 0, u_valuename); -#endif } else { @@ -1357,15 +1321,15 @@ done: return result; } -static LONG CopyKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR lpSrcSubKey) +static LONG CopyKey(HKEY hDestKey, LPCWSTR lpDestSubKey, HKEY hSrcKey, LPCWSTR lpSrcSubKey) { LONG lResult; DWORD dwDisposition; HKEY hDestSubKey = NULL; HKEY hSrcSubKey = NULL; DWORD dwIndex, dwType, cbName, cbData; - TCHAR szSubKey[256]; - TCHAR szValueName[256]; + WCHAR szSubKey[256]; + WCHAR szValueName[256]; BYTE szValueData[512]; FILETIME ft; @@ -1373,14 +1337,14 @@ static LONG CopyKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR l /* open the source subkey, if specified */ if (lpSrcSubKey) { - lResult = RegOpenKeyEx(hSrcKey, lpSrcSubKey, 0, KEY_ALL_ACCESS, &hSrcSubKey); + lResult = RegOpenKeyExW(hSrcKey, lpSrcSubKey, 0, KEY_ALL_ACCESS, &hSrcSubKey); if (lResult) goto done; hSrcKey = hSrcSubKey; } /* create the destination subkey */ - lResult = RegCreateKeyEx(hDestKey, lpDestSubKey, 0, NULL, 0, KEY_WRITE, NULL, + lResult = RegCreateKeyExW(hDestKey, lpDestSubKey, 0, NULL, 0, KEY_WRITE, NULL, &hDestSubKey, &dwDisposition); if (lResult) goto done; @@ -1390,7 +1354,7 @@ static LONG CopyKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR l do { cbName = sizeof(szSubKey) / sizeof(szSubKey[0]); - lResult = RegEnumKeyEx(hSrcKey, dwIndex++, szSubKey, &cbName, NULL, NULL, NULL, &ft); + lResult = RegEnumKeyExW(hSrcKey, dwIndex++, szSubKey, &cbName, NULL, NULL, NULL, &ft); if (lResult == ERROR_SUCCESS) { lResult = CopyKey(hDestSubKey, szSubKey, hSrcKey, szSubKey); @@ -1406,10 +1370,10 @@ static LONG CopyKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR l { cbName = sizeof(szValueName) / sizeof(szValueName[0]); cbData = sizeof(szValueData) / sizeof(szValueData[0]); - lResult = RegEnumValue(hSrcKey, dwIndex++, szValueName, &cbName, NULL, &dwType, szValueData, &cbData); + lResult = RegEnumValueW(hSrcKey, dwIndex++, szValueName, &cbName, NULL, &dwType, szValueData, &cbData); if (lResult == ERROR_SUCCESS) { - lResult = RegSetValueEx(hDestSubKey, szValueName, 0, dwType, szValueData, cbData); + lResult = RegSetValueExW(hDestSubKey, szValueName, 0, dwType, szValueData, cbData); if (lResult) goto done; } @@ -1428,7 +1392,7 @@ done: return lResult; } -static LONG MoveKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR lpSrcSubKey) +static LONG MoveKey(HKEY hDestKey, LPCWSTR lpDestSubKey, HKEY hSrcKey, LPCWSTR lpSrcSubKey) { LONG lResult; @@ -1442,24 +1406,24 @@ static LONG MoveKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR l return lResult; } -BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath) +BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath) { - TCHAR msg[128], caption[128]; + WCHAR msg[128], caption[128]; BOOL result = FALSE; LONG lRet; HKEY hKey; - lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_READ|KEY_SET_VALUE, &hKey); + lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ|KEY_SET_VALUE, &hKey); if (lRet != ERROR_SUCCESS) { error_code_messagebox(hwnd, lRet); return FALSE; } - LoadString(hInst, IDS_QUERY_DELETE_KEY_CONFIRM, caption, COUNT_OF(caption)); - LoadString(hInst, IDS_QUERY_DELETE_KEY_ONE, msg, COUNT_OF(msg)); + LoadStringW(hInst, IDS_QUERY_DELETE_KEY_CONFIRM, caption, COUNT_OF(caption)); + LoadStringW(hInst, IDS_QUERY_DELETE_KEY_ONE, msg, COUNT_OF(msg)); - if (MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) != IDYES) + if (MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) != IDYES) goto done; lRet = SHDeleteKey(hKeyRoot, keyPath); @@ -1475,24 +1439,24 @@ done: return result; } -LONG RenameKey(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpNewName) +LONG RenameKey(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpNewName) { - LPCTSTR s; - LPTSTR lpNewSubKey = NULL; + LPCWSTR s; + LPWSTR lpNewSubKey = NULL; LONG Ret = 0; if (!lpSubKey) return Ret; - s = _tcsrchr(lpSubKey, _T('\\')); + s = wcsrchr(lpSubKey, L'\\'); if (s) { s++; - lpNewSubKey = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, (s - lpSubKey + _tcslen(lpNewName) + 1) * sizeof(TCHAR)); + lpNewSubKey = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (s - lpSubKey + wcslen(lpNewName) + 1) * sizeof(WCHAR)); if (lpNewSubKey != NULL) { - memcpy(lpNewSubKey, lpSubKey, (s - lpSubKey) * sizeof(TCHAR)); - lstrcpy(lpNewSubKey + (s - lpSubKey), lpNewName); + memcpy(lpNewSubKey, lpSubKey, (s - lpSubKey) * sizeof(WCHAR)); + wcscpy(lpNewSubKey + (s - lpSubKey), lpNewName); lpNewName = lpNewSubKey; } else @@ -1508,7 +1472,7 @@ LONG RenameKey(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpNewName) return Ret; } -LONG RenameValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpDestValue, LPCTSTR lpSrcValue) +LONG RenameValue(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpDestValue, LPCWSTR lpSrcValue) { LONG lResult; HKEY hSubKey = NULL; @@ -1517,18 +1481,18 @@ LONG RenameValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpDestValue, LPCTSTR lpSrc if (lpSubKey) { - lResult = RegOpenKey(hKey, lpSubKey, &hSubKey); + lResult = RegOpenKeyW(hKey, lpSubKey, &hSubKey); if (lResult != ERROR_SUCCESS) goto done; hKey = hSubKey; } cbData = sizeof(data); - lResult = RegQueryValueEx(hKey, lpSrcValue, NULL, &dwType, data, &cbData); + lResult = RegQueryValueExW(hKey, lpSrcValue, NULL, &dwType, data, &cbData); if (lResult != ERROR_SUCCESS) goto done; - lResult = RegSetValueEx(hKey, lpDestValue, 0, dwType, data, cbData); + lResult = RegSetValueExW(hKey, lpDestValue, 0, dwType, data, cbData); if (lResult != ERROR_SUCCESS) goto done; @@ -1540,7 +1504,7 @@ done: return lResult; } -LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen) +LONG QueryStringValue(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR pszBuffer, DWORD dwBufferLen) { LONG lResult; HKEY hSubKey = NULL; @@ -1548,14 +1512,14 @@ LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR p if (lpSubKey) { - lResult = RegOpenKey(hKey, lpSubKey, &hSubKey); + lResult = RegOpenKeyW(hKey, lpSubKey, &hSubKey); if (lResult != ERROR_SUCCESS) goto done; hKey = hSubKey; } cbData = (dwBufferLen - 1) * sizeof(*pszBuffer); - lResult = RegQueryValueEx(hKey, lpValueName, NULL, &dwType, (LPBYTE) pszBuffer, &cbData); + lResult = RegQueryValueExW(hKey, lpValueName, NULL, &dwType, (LPBYTE) pszBuffer, &cbData); if (lResult != ERROR_SUCCESS) goto done; if (dwType != REG_SZ) @@ -1564,38 +1528,38 @@ LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR p goto done; } - pszBuffer[cbData / sizeof(*pszBuffer)] = _T('\0'); + pszBuffer[cbData / sizeof(*pszBuffer)] = L'\0'; done: if (lResult != ERROR_SUCCESS) - pszBuffer[0] = _T('\0'); + pszBuffer[0] = L'\0'; if (hSubKey) RegCloseKey(hSubKey); return lResult; } -BOOL GetKeyName(LPTSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCTSTR lpSubKey) +BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey) { - LPCTSTR pszRootKey; + LPCWSTR pszRootKey; if (hRootKey == HKEY_CLASSES_ROOT) - pszRootKey = TEXT("HKEY_CLASSES_ROOT"); + pszRootKey = L"HKEY_CLASSES_ROOT"; else if (hRootKey == HKEY_CURRENT_USER) - pszRootKey = TEXT("HKEY_CURRENT_USER"); + pszRootKey = L"HKEY_CURRENT_USER"; else if (hRootKey == HKEY_LOCAL_MACHINE) - pszRootKey = TEXT("HKEY_LOCAL_MACHINE"); + pszRootKey = L"HKEY_LOCAL_MACHINE"; else if (hRootKey == HKEY_USERS) - pszRootKey = TEXT("HKEY_USERS"); + pszRootKey = L"HKEY_USERS"; else if (hRootKey == HKEY_CURRENT_CONFIG) - pszRootKey = TEXT("HKEY_CURRENT_CONFIG"); + pszRootKey = L"HKEY_CURRENT_CONFIG"; else if (hRootKey == HKEY_DYN_DATA) - pszRootKey = TEXT("HKEY_DYN_DATA"); + pszRootKey = L"HKEY_DYN_DATA"; else return FALSE; if (lpSubKey[0]) - _sntprintf(pszDest, iDestLength, TEXT("%s\\%s"), pszRootKey, lpSubKey); + _snwprintf(pszDest, iDestLength, L"%s\\%s", pszRootKey, lpSubKey); else - _sntprintf(pszDest, iDestLength, TEXT("%s"), pszRootKey); + _snwprintf(pszDest, iDestLength, L"%s", pszRootKey); return TRUE; } diff --git a/reactos/base/applications/regedit/error.c b/reactos/base/applications/regedit/error.c index 864094e223f..631359154df 100644 --- a/reactos/base/applications/regedit/error.c +++ b/reactos/base/applications/regedit/error.c @@ -21,56 +21,56 @@ #include -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; } diff --git a/reactos/base/applications/regedit/find.c b/reactos/base/applications/regedit/find.c index 4283864854d..0a15204a924 100644 --- a/reactos/base/applications/regedit/find.c +++ b/reactos/base/applications/regedit/find.c @@ -20,69 +20,69 @@ #include #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); } } } diff --git a/reactos/base/applications/regedit/framewnd.c b/reactos/base/applications/regedit/framewnd.c index 6ff137183f6..1f5023d5e76 100644 --- a/reactos/base/applications/regedit/framewnd.c +++ b/reactos/base/applications/regedit/framewnd.c @@ -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; } diff --git a/reactos/base/applications/regedit/hexedit.c b/reactos/base/applications/regedit/hexedit.c index 78afe08af4c..209287ab20c 100644 --- a/reactos/base/applications/regedit/hexedit.c +++ b/reactos/base/applications/regedit/hexedit.c @@ -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); } diff --git a/reactos/base/applications/regedit/hexedit.h b/reactos/base/applications/regedit/hexedit.h index 5ee5e22992d..0e480edcea5 100644 --- a/reactos/base/applications/regedit/hexedit.h +++ b/reactos/base/applications/regedit/hexedit.h @@ -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 */ diff --git a/reactos/base/applications/regedit/listview.c b/reactos/base/applications/regedit/listview.c index b781eb59ac0..ccc1107649a 100644 --- a/reactos/base/applications/regedit/listview.c +++ b/reactos/base/applications/regedit/listview.c @@ -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; } diff --git a/reactos/base/applications/regedit/main.c b/reactos/base/applications/regedit/main.c index f40a6f1e1a3..0afc57d5ad7 100644 --- a/reactos/base/applications/regedit/main.c +++ b/reactos/base/applications/regedit/main.c @@ -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 */ diff --git a/reactos/base/applications/regedit/main.h b/reactos/base/applications/regedit/main.h index d8931dc0577..46ade6bf2fd 100644 --- a/reactos/base/applications/regedit/main.h +++ b/reactos/base/applications/regedit/main.h @@ -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 */ diff --git a/reactos/base/applications/regedit/regedit.c b/reactos/base/applications/regedit/regedit.c index aea971ff07b..66ce69f1005 100644 --- a/reactos/base/applications/regedit/regedit.c +++ b/reactos/base/applications/regedit/regedit.c @@ -21,37 +21,37 @@ #include -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; diff --git a/reactos/base/applications/regedit/regedit.h b/reactos/base/applications/regedit/regedit.h index bcf262041e2..fba55ee8d3d 100644 --- a/reactos/base/applications/regedit/regedit.h +++ b/reactos/base/applications/regedit/regedit.h @@ -12,7 +12,7 @@ #include #include #include -#include +//#include #include #include #include @@ -29,4 +29,7 @@ #include "regproc.h" #include "hexedit.h" #include "security.h" + #endif + +/* EOF */ diff --git a/reactos/base/applications/regedit/regproc.c b/reactos/base/applications/regedit/regproc.c index d76fda1c588..69604e8e897 100644 --- a/reactos/base/applications/regedit/regproc.c +++ b/reactos/base/applications/regedit/regproc.c @@ -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, ®_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); diff --git a/reactos/base/applications/regedit/regproc.h b/reactos/base/applications/regedit/regproc.h index e6412459481..907a860e31d 100644 --- a/reactos/base/applications/regedit/regproc.h +++ b/reactos/base/applications/regedit/regproc.h @@ -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); diff --git a/reactos/base/applications/regedit/resource.h b/reactos/base/applications/regedit/resource.h index 4cbb7294870..176711f1504 100644 --- a/reactos/base/applications/regedit/resource.h +++ b/reactos/base/applications/regedit/resource.h @@ -293,5 +293,4 @@ #define ID_ACCEL 3000 - #define IDC_STATIC -1 diff --git a/reactos/base/applications/regedit/security.c b/reactos/base/applications/regedit/security.c index c56487c5712..69c4ca246ac 100644 --- a/reactos/base/applications/regedit/security.c +++ b/reactos/base/applications/regedit/security.c @@ -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(), diff --git a/reactos/base/applications/regedit/security.h b/reactos/base/applications/regedit/security.h index 4f6d70dd5ef..d520b916284 100644 --- a/reactos/base/applications/regedit/security.h +++ b/reactos/base/applications/regedit/security.h @@ -150,7 +150,7 @@ typedef struct _CRegKeySecurity SI_OBJECT_INFO ObjectInfo; BOOL *Btn; HKEY hRootKey; - TCHAR szRegKey[1]; + WCHAR szRegKey[1]; } CRegKeySecurity, *PCRegKeySecurity; /* EOF */ diff --git a/reactos/base/applications/regedit/settings.c b/reactos/base/applications/regedit/settings.c index ec05738c8d9..7c6612d21d8 100644 --- a/reactos/base/applications/regedit/settings.c +++ b/reactos/base/applications/regedit/settings.c @@ -21,7 +21,7 @@ #include -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 */ diff --git a/reactos/base/applications/regedit/treeview.c b/reactos/base/applications/regedit/treeview.c index 288b8950473..3a5cbf8683a 100644 --- a/reactos/base/applications/regedit/treeview.c +++ b/reactos/base/applications/regedit/treeview.c @@ -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 */ -- 2.17.1