From 9792217df9b16dfccf2bd9e20d62a7ef580ef0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Tue, 1 Jan 2013 19:38:47 +0000 Subject: [PATCH] [REGEDIT] - Revert lstrcpynW --> wcsncpy changes from r57471 back to lstrcpynW because this function automatically NULL-terminate strings (but I wonder if there is a replacement of lstrcpynW which has all its functionalities, in the CRT). This fixes address loading after editing it in the address bar. Caught by Edijus ;) - Unicodize a little bit more regedit. svn path=/trunk/; revision=58090 --- reactos/base/applications/regedit/childwnd.c | 28 ++++++++--------- reactos/base/applications/regedit/edit.c | 16 +++++----- reactos/base/applications/regedit/find.c | 10 +++--- reactos/base/applications/regedit/framewnd.c | 4 +-- reactos/base/applications/regedit/listview.c | 8 ++--- reactos/base/applications/regedit/treeview.c | 32 ++++++++++---------- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/reactos/base/applications/regedit/childwnd.c b/reactos/base/applications/regedit/childwnd.c index d8b40e718ed..a55310a95b1 100644 --- a/reactos/base/applications/regedit/childwnd.c +++ b/reactos/base/applications/regedit/childwnd.c @@ -236,16 +236,16 @@ static void SuggestKeys(HKEY hRootKey, LPCWSTR pszKeyPath, LPWSTR pszSuggestions { /* Sanity check this key; it cannot be empty, nor can it be a * loop back */ - if ((szBuffer[0] != L'\0') && wcsicmp(szBuffer, pszKeyPath)) + if ((szBuffer[0] != L'\0') && _wcsicmp(szBuffer, pszKeyPath)) { if (RegOpenKeyW(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS) { - wcsncpy(pszSuggestions, L"HKCR\\", (int) iSuggestionsLength); + lstrcpynW(pszSuggestions, L"HKCR\\", (int) iSuggestionsLength); i = wcslen(pszSuggestions); pszSuggestions += i; iSuggestionsLength -= i; - wcsncpy(pszSuggestions, szBuffer, (int) iSuggestionsLength); + lstrcpynW(pszSuggestions, szBuffer, (int) iSuggestionsLength); i = MIN(wcslen(pszSuggestions) + 1, iSuggestionsLength); pszSuggestions += i; iSuggestionsLength -= i; @@ -266,12 +266,12 @@ static void SuggestKeys(HKEY hRootKey, LPCWSTR pszKeyPath, LPWSTR pszSuggestions if (QueryStringValue(hSubKey, L"CLSID", NULL, szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS) { - wcsncpy(pszSuggestions, L"HKCR\\CLSID\\", (int)iSuggestionsLength); + lstrcpynW(pszSuggestions, L"HKCR\\CLSID\\", (int)iSuggestionsLength); i = wcslen(pszSuggestions); pszSuggestions += i; iSuggestionsLength -= i; - wcsncpy(pszSuggestions, szBuffer, (int)iSuggestionsLength); + lstrcpynW(pszSuggestions, szBuffer, (int)iSuggestionsLength); i = MIN(wcslen(pszSuggestions) + 1, iSuggestionsLength); pszSuggestions += i; iSuggestionsLength -= i; @@ -286,7 +286,7 @@ LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar { WNDPROC oldwndproc; static WCHAR s_szNode[256]; - oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWL_USERDATA); + oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (uMsg) { @@ -300,7 +300,7 @@ LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar default: break; } - return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam); + return CallWindowProcW(oldwndproc, hwnd, uMsg, wParam, lParam); } static VOID @@ -333,8 +333,8 @@ UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath) 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 (!(wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") && - wcsicmp(rootName, L"HKEY_USERS"))) + if (!(_wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") && + _wcsicmp(rootName, L"HKEY_USERS"))) { /* * enable the unload menu item if at the root, otherwise @@ -406,9 +406,9 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa 0); } /* Subclass the AddressBar */ - oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWL_WNDPROC); - SetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWL_USERDATA, (DWORD_PTR)oldproc); - SetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWL_WNDPROC, (DWORD_PTR)AddressBarProc); + oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWLP_WNDPROC); + SetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWLP_USERDATA, (DWORD_PTR)oldproc); + SetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWLP_WNDPROC, (DWORD_PTR)AddressBarProc); break; } case WM_COMMAND: @@ -660,8 +660,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa { TVHITTESTINFO hti; HMENU hContextMenu; - TVITEM item; - MENUITEMINFO mii; + TVITEMW item; + MENUITEMINFOW mii; WCHAR resource[256]; WCHAR buffer[256]; LPWSTR s; diff --git a/reactos/base/applications/regedit/edit.c b/reactos/base/applications/regedit/edit.c index f154a11b870..3ec9e1448bc 100644 --- a/reactos/base/applications/regedit/edit.c +++ b/reactos/base/applications/regedit/edit.c @@ -230,7 +230,7 @@ LRESULT CALLBACK DwordEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR { WNDPROC oldwndproc; - oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWL_USERDATA); + oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (uMsg) { @@ -263,7 +263,7 @@ LRESULT CALLBACK DwordEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR } } - return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam); + return CallWindowProcW(oldwndproc, hwnd, uMsg, wParam, lParam); } @@ -285,9 +285,9 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP /* subclass the edit control */ hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA); - oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwndValue, GWL_WNDPROC); - SetWindowLongPtr(hwndValue, GWL_USERDATA, (DWORD_PTR)oldproc); - SetWindowLongPtr(hwndValue, GWL_WNDPROC, (DWORD_PTR)DwordEditSubclassProc); + oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwndValue, GWLP_WNDPROC); + SetWindowLongPtr(hwndValue, GWLP_USERDATA, (DWORD_PTR)oldproc); + SetWindowLongPtr(hwndValue, GWLP_WNDPROC, (DWORD_PTR)DwordEditSubclassProc); if (editValueName && wcscmp(editValueName, L"")) { @@ -665,7 +665,7 @@ ParseResources(HWND hwnd) HWND hwndLV; WCHAR buffer[80]; - LVITEM item; + LVITEMW item; INT iItem; pFullDescriptor = &resourceValueData->List[fullResourceIndex]; @@ -866,7 +866,7 @@ OnResourceNotify(HWND hwndDlg, NMHDR *phdr) if (lpnmlv->iItem != -1) { PCM_PARTIAL_RESOURCE_DESCRIPTOR pDescriptor; - LVITEM item; + LVITEMW item; item.mask = LVIF_PARAM; item.iItem = lpnmlv->iItem; @@ -968,7 +968,7 @@ static VOID AddFullResourcesToList(HWND hwnd) { PCM_FULL_RESOURCE_DESCRIPTOR pFullDescriptor; WCHAR buffer[80]; - LVITEM item; + LVITEMW item; ULONG i; INT iItem; diff --git a/reactos/base/applications/regedit/find.c b/reactos/base/applications/regedit/find.c index c0a1500d83c..3c3e7d4cc0c 100644 --- a/reactos/base/applications/regedit/find.c +++ b/reactos/base/applications/regedit/find.c @@ -77,7 +77,7 @@ static BOOL CompareName(LPCWSTR pszName1, LPCWSTR pszName2) if (s_dwFlags & RSF_MATCHCASE) return wcscmp(pszName1, pszName2) == 0; else - return wcsicmp(pszName1, pszName2) == 0; + return _wcsicmp(pszName1, pszName2) == 0; } else { @@ -130,7 +130,7 @@ int compare(const void *x, const void *y) { const LPCWSTR *a = (const LPCWSTR *)x; const LPCWSTR *b = (const LPCWSTR *)y; - return wcsicmp(*a, *b); + return _wcsicmp(*a, *b); } BOOL RegFindRecurse( @@ -198,7 +198,7 @@ BOOL RegFindRecurse( if (DoEvents()) goto err; - if (!fPast && wcsicmp(ppszNames[i], pszValueName) == 0) + if (!fPast && _wcsicmp(ppszNames[i], pszValueName) == 0) { fPast = TRUE; continue; @@ -390,7 +390,7 @@ BOOL RegFindWalk( } else { - wcsncpy(szKeyName, pch + 1, MAX_PATH); + lstrcpynW(szKeyName, pch + 1, MAX_PATH); *pch = 0; lResult = RegOpenKeyExW(hBaseKey, szSubKey, 0, KEY_ALL_ACCESS, &hSubKey); @@ -434,7 +434,7 @@ BOOL RegFindWalk( if (DoEvents()) goto err; - if (!fPast && wcsicmp(ppszNames[i], szKeyName) == 0) + if (!fPast && _wcsicmp(ppszNames[i], szKeyName) == 0) { fPast = TRUE; continue; diff --git a/reactos/base/applications/regedit/framewnd.c b/reactos/base/applications/regedit/framewnd.c index 19b8a8e4bfb..d94534abb0a 100644 --- a/reactos/base/applications/regedit/framewnd.c +++ b/reactos/base/applications/regedit/framewnd.c @@ -453,7 +453,7 @@ static BOOL ImportRegistryFile(HWND hWnd) { /* Look at the extension of the file to determine its type */ if (ofn.nFileExtension >= 1 && - wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"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"); @@ -1249,7 +1249,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if ((LOWORD(wParam) >= ID_FAVORITES_MIN) && (LOWORD(wParam) <= ID_FAVORITES_MAX)) { HMENU hMenu; - MENUITEMINFO mii; + MENUITEMINFOW mii; WCHAR szFavorite[512]; hMenu = GetSubMenu(GetMenu(hWnd), FAVORITES_MENU_POSITION); diff --git a/reactos/base/applications/regedit/listview.c b/reactos/base/applications/regedit/listview.c index 2d7970a33c6..958c50f1550 100644 --- a/reactos/base/applications/regedit/listview.c +++ b/reactos/base/applications/regedit/listview.c @@ -56,7 +56,7 @@ static const int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT LPCWSTR GetValueName(HWND hwndLV, int iStartAt) { int item; - LVITEM LVItem; + LVITEMW LVItem; PLINE_INFO lineinfo; /* @@ -108,7 +108,7 @@ VOID SetValueName(HWND hwndLV, LPCWSTR pszValueName) BOOL IsDefaultValue(HWND hwndLV, int i) { PLINE_INFO lineinfo; - LVITEM Item; + LVITEMW Item; Item.mask = LVIF_PARAM; Item.iItem = i; @@ -126,7 +126,7 @@ BOOL IsDefaultValue(HWND hwndLV, int i) static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType, void* ValBuf, DWORD dwCount, int Position, BOOL ValExists) { PLINE_INFO linfo; - LVITEM item; + LVITEMW item; int index; linfo = (PLINE_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINE_INFO) + dwCount); @@ -654,7 +654,7 @@ fail: void DestroyListView(HWND hwndLV) { INT count, i; - LVITEM item; + LVITEMW item; count = ListView_GetItemCount(hwndLV); for (i = 0; i < count; i++) diff --git a/reactos/base/applications/regedit/treeview.c b/reactos/base/applications/regedit/treeview.c index 471294706fc..f27299c9671 100644 --- a/reactos/base/applications/regedit/treeview.c +++ b/reactos/base/applications/regedit/treeview.c @@ -34,7 +34,7 @@ static LPWSTR pathBuffer; static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPWSTR* pKeyPath, int* pPathLen, int* pMaxLen) { - TVITEM item; + TVITEMW item; size_t maxLen, len; LPWSTR newStr; @@ -109,8 +109,8 @@ 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, LPWSTR label, HKEY hKey, DWORD dwChildren) { - TVITEM tvi; - TVINSERTSTRUCT tvins; + TVITEMW tvi; + TVINSERTSTRUCTW tvins; if (hKey) { @@ -140,7 +140,7 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) LPCWSTR KeyPath; DWORD dwCount, dwIndex, dwMaxSubKeyLen; LPWSTR Name = NULL; - TVITEM tvItem; + TVITEMW tvItem; LPWSTR pszNodes = NULL; BOOL bSuccess = FALSE; LPWSTR s; @@ -332,7 +332,7 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name) { WCHAR buf[MAX_NEW_KEY_LEN]; HTREEITEM hNewItem = 0; - TVITEMEX item; + TVITEMEXW item; /* Default to the current selection */ if (!hItem) @@ -390,8 +390,8 @@ HWND StartKeyRename(HWND hwndTV) static BOOL InitTreeViewItems(HWND hwndTV, LPWSTR pHostName) { - TVITEM tvi; - TVINSERTSTRUCT tvins; + TVITEMW tvi; + TVINSERTSTRUCTW tvins; HTREEITEM hRoot; tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM; @@ -664,7 +664,7 @@ BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath) WCHAR szPathPart[128]; WCHAR szBuffer[128]; LPCWSTR s; - TVITEM tvi; + TVITEMW tvi; /* Load "My Computer" string... */ LoadStringW(hInst, IDS_MY_COMPUTER, szBuffer, COUNT_OF(szBuffer)); @@ -683,22 +683,22 @@ BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath) while(keyPath[0]) { s = wcschr(keyPath, L'\\'); - wcsncpy(szPathPart, keyPath, s ? s - keyPath + 1 : wcslen(keyPath) + 1); + lstrcpynW(szPathPart, keyPath, s ? s - keyPath + 1 : wcslen(keyPath) + 1); /* Special case for root to expand root key abbreviations */ if (hItem == hRoot) { - if (!wcsicmp(szPathPart, L"HKCR")) + if (!_wcsicmp(szPathPart, L"HKCR")) wcscpy(szPathPart, L"HKEY_CLASSES_ROOT"); - else if (!wcsicmp(szPathPart, L"HKCU")) + else if (!_wcsicmp(szPathPart, L"HKCU")) wcscpy(szPathPart, L"HKEY_CURRENT_USER"); - else if (!wcsicmp(szPathPart, L"HKLM")) + else if (!_wcsicmp(szPathPart, L"HKLM")) wcscpy(szPathPart, L"HKEY_LOCAL_MACHINE"); - else if (!wcsicmp(szPathPart, L"HKU")) + else if (!_wcsicmp(szPathPart, L"HKU")) wcscpy(szPathPart, L"HKEY_USERS"); - else if (!wcsicmp(szPathPart, L"HKCC")) + else if (!_wcsicmp(szPathPart, L"HKCC")) wcscpy(szPathPart, L"HKEY_CURRENT_CONFIG"); - else if (!wcsicmp(szPathPart, L"HKDD")) + else if (!_wcsicmp(szPathPart, L"HKDD")) wcscpy(szPathPart, L"HKEY_DYN_DATA"); } @@ -713,7 +713,7 @@ BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath) (void)TreeView_GetItem(hwndTV, &tvi); - if (!wcsicmp(szBuffer, szPathPart)) + if (!_wcsicmp(szBuffer, szPathPart)) break; }