[SYSDM]
authorEric Kohl <eric.kohl@reactos.org>
Mon, 18 May 2015 20:29:14 +0000 (20:29 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 18 May 2015 20:29:14 +0000 (20:29 +0000)
The maximum length of hardware profiles names is 79 characters. Use a matching string length and set the length of the edit control accordingly.

svn path=/trunk/; revision=67825

reactos/dll/cpl/sysdm/hardprof.c

index d24cf09..27a5c4e 100644 (file)
 
 #include <debug.h>
 
+#define PROFILE_NAME_LENGTH 80
+
 typedef struct _PROFILE
 {
-    WCHAR szFriendlyName[256];
+    WCHAR szFriendlyName[PROFILE_NAME_LENGTH];
     WCHAR szName[5];
     DWORD dwProfileNumber;
     DWORD dwPreferenceOrder;
@@ -37,11 +39,12 @@ OnCopyProfileInit(HWND hwndDlg,
                   UINT idFrom,
                   UINT idTo)
 {
-    WCHAR szNewProfileName[256];
+    WCHAR szNewProfileName[PROFILE_NAME_LENGTH];
 
     SetDlgItemText(hwndDlg, idFrom, pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex].szFriendlyName);
 
     swprintf(szNewProfileName, L"Profile %lu", pProfileData->dwProfileCount);
+    SendDlgItemMessageW(hwndDlg, idTo, EM_SETLIMITTEXT, PROFILE_NAME_LENGTH - 1, 0);
     SetDlgItemText(hwndDlg, idTo, szNewProfileName);
 }
 
@@ -76,7 +79,7 @@ CopyProfile(
     GetDlgItemText(hwndDlg,
                    IDC_COPYPROFILETO,
                    pDstProfile->szFriendlyName,
-                   256);
+                   PROFILE_NAME_LENGTH);
 
     pDstProfile->dwProfileNumber = ++pProfileData->dwLastProfile;
     swprintf(pDstProfile->szName, L"%04lu", pDstProfile->dwProfileNumber);
@@ -138,7 +141,7 @@ RenameProfile(
     GetDlgItemText(hwndDlg,
                    IDC_RENPROFEDITTO,
                    pProfile->szFriendlyName,
-                   256);
+                   PROFILE_NAME_LENGTH);
 
     /* Replace the listbox string */
     SendDlgItemMessageW(pProfileData->hwndProfileDlg, IDC_HRDPROFLSTBOX, LB_DELETESTRING, pProfileData->dwSelectedProfileIndex, 0);
@@ -288,7 +291,7 @@ GetProfile(
     if (lError != ERROR_SUCCESS)
         return;
 
-    dwSize = 256 * sizeof(WCHAR);
+    dwSize = PROFILE_NAME_LENGTH * sizeof(WCHAR);
     lError = RegQueryValueExW(hProfileKey,
                               L"FriendlyName",
                               NULL,