Synchronize with trunk revision 59636 (just before Alex's CreateProcess revamp).
[reactos.git] / base / applications / regedit / framewnd.c
index 5c47c94..7510472 100644 (file)
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <regedit.h>
+#include "regedit.h"
 
 /********************************************************************************
  * Global and Local Variables:
@@ -288,20 +288,21 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
     return TRUE;
 }
 
+#define LOADHIVE_KEYNAMELENGTH 128
+
 static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
     static LPWSTR sKey = NULL;
-    static INT sLength = 0;
     switch(uMsg)
     {
     case WM_INITDIALOG:
         sKey = (LPWSTR)lParam;
-        sLength = 128; /* FIXME: Ugly hack! */
+        break;
     case WM_COMMAND:
         switch(LOWORD(wParam))
         {
         case IDOK:
-            if(GetDlgItemTextW(hWndDlg, IDC_EDIT_KEY, sKey, sLength))
+            if(GetDlgItemTextW(hWndDlg, IDC_EDIT_KEY, sKey, LOADHIVE_KEYNAMELENGTH))
                 return EndDialog(hWndDlg, -1);
             else
                 return EndDialog(hWndDlg, 0);
@@ -348,7 +349,7 @@ static BOOL LoadHive(HWND hWnd)
     OPENFILENAME ofn;
     WCHAR Caption[128];
     LPCWSTR pszKeyPath;
-    WCHAR xPath[128];
+    WCHAR xPath[LOADHIVE_KEYNAMELENGTH];
     HKEY hRootKey;
     WCHAR Filter[1024];
     FILTERPAIR filter;
@@ -369,7 +370,8 @@ static BOOL LoadHive(HWND hWnd)
     /* now load the hive */
     if (GetOpenFileName(&ofn))
     {
-        if(DialogBoxParamW(hInst, MAKEINTRESOURCEW(IDD_LOADHIVE), hWnd, &LoadHive_KeyNameInHookProc, (LPARAM)xPath))
+        if (DialogBoxParamW(hInst, MAKEINTRESOURCEW(IDD_LOADHIVE), hWnd,
+                            &LoadHive_KeyNameInHookProc, (LPARAM)xPath))
         {
             LONG regLoadResult;
 
@@ -451,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");
@@ -851,10 +853,19 @@ static BOOL CreateNewValue(HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType)
             cbData = sizeof(WCHAR);
             break;
         case REG_MULTI_SZ:
-            cbData = sizeof(WCHAR) * 2;
+            /*
+             * WARNING: An empty multi-string has only one null char.
+             * Indeed, multi-strings are built in the following form:
+             * str1\0str2\0...strN\0\0
+             * where each strI\0 is a null-terminated string, and it
+             * ends with a terminating empty string.
+             * Therefore an empty multi-string contains only the terminating
+             * empty string, that is, one null char.
+             */
+            cbData = sizeof(WCHAR);
             break;
-        case REG_QWORD:
-            cbData = sizeof(DWORD) * 2;
+        case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
+            cbData = sizeof(DWORDLONG); // == sizeof(DWORD) * 2;
             break;
         default:
             cbData = 0;
@@ -1247,7 +1258,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);