[RAPPS][RAPPS_NEW]: Try to not hardcode types of variables in sizeofs, and use _count...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 6 Oct 2016 12:22:32 +0000 (12:22 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 6 Oct 2016 12:22:32 +0000 (12:22 +0000)
svn path=/trunk/; revision=72918

18 files changed:
reactos/base/applications/rapps/installed.c
reactos/base/applications/rapps/listview.c
reactos/base/applications/rapps/loaddlg.c
reactos/base/applications/rapps/misc.c
reactos/base/applications/rapps/richedit.c
reactos/base/applications/rapps/settingsdlg.c
reactos/base/applications/rapps/splitter.c
reactos/base/applications/rapps/toolbar.c
reactos/base/applications/rapps/treeview.c
reactos/base/applications/rapps/winmain.c
reactos/base/applications/rapps_new/crichedit.h
reactos/base/applications/rapps_new/gui.cpp
reactos/base/applications/rapps_new/installed.cpp
reactos/base/applications/rapps_new/loaddlg.cpp
reactos/base/applications/rapps_new/misc.cpp
reactos/base/applications/rapps_new/settingsdlg.cpp
reactos/base/applications/rapps_new/splitter.cpp
reactos/base/applications/rapps_new/winmain.cpp

index 18cec23..7a13693 100644 (file)
@@ -104,10 +104,10 @@ UninstallApplication(INT Index, BOOL bModify)
         ItemIndex = Index;
     }
 
-    ListView_GetItemText(hListView, ItemIndex, 0, szAppName, sizeof(szAppName) / sizeof(WCHAR));
+    ListView_GetItemText(hListView, ItemIndex, 0, szAppName, _countof(szAppName));
     WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szAppName);
 
-    ZeroMemory(&Item, sizeof(LVITEM));
+    ZeroMemory(&Item, sizeof(Item));
 
     Item.mask = LVIF_PARAM;
     Item.iItem = ItemIndex;
@@ -149,7 +149,7 @@ ShowInstalledAppInfo(INT Index)
 #define GET_INFO(a, b, c, d) \
     if (GetApplicationString(Info->hSubKey, a, szInfo)) \
     { \
-        LoadStringW(hInst, b, szText, sizeof(szText) / sizeof(WCHAR)); \
+        LoadStringW(hInst, b, szText, _countof(szText)); \
         InsertRichEditText(szText, c); \
         InsertRichEditText(szInfo, d); \
     } \
@@ -190,8 +190,8 @@ RemoveAppFromRegistry(INT Index)
     Info = ListViewGetlParam(Index);
     if (!Info || !Info->hSubKey || (ItemIndex == -1)) return;
 
-    if (!LoadStringW(hInst, IDS_APP_REG_REMOVE, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)) ||
-        !LoadStringW(hInst, IDS_INFORMATION, szMsgTitle, sizeof(szMsgTitle) / sizeof(WCHAR)))
+    if (!LoadStringW(hInst, IDS_APP_REG_REMOVE, szMsgText, _countof(szMsgText)) ||
+        !LoadStringW(hInst, IDS_INFORMATION, szMsgTitle, _countof(szMsgTitle)))
         return;
 
     if (MessageBoxW(hMainWnd, szMsgText, szMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
@@ -204,7 +204,7 @@ RemoveAppFromRegistry(INT Index)
             return;
         }
 
-        if (!LoadStringW(hInst, IDS_UNABLE_TO_REMOVE, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
+        if (!LoadStringW(hInst, IDS_UNABLE_TO_REMOVE, szMsgText, _countof(szMsgText)))
             return;
 
         MessageBoxW(hMainWnd, szMsgText, NULL, MB_OK | MB_ICONERROR);
index 7c65cab..d4041e2 100644 (file)
@@ -28,7 +28,7 @@ ListViewGetlParam(INT Index)
         ItemIndex = Index;
     }
 
-    ZeroMemory(&Item, sizeof(LVITEM));
+    ZeroMemory(&Item, sizeof(Item));
 
     Item.mask = LVIF_PARAM;
     Item.iItem = ItemIndex;
@@ -43,7 +43,7 @@ ListViewAddColumn(INT Index, LPWSTR lpText, INT Width, INT Format)
 {
     LV_COLUMN Column;
 
-    ZeroMemory(&Column, sizeof(LV_COLUMN));
+    ZeroMemory(&Column, sizeof(Column));
 
     Column.mask     = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
     Column.iSubItem = Index;
@@ -59,7 +59,7 @@ ListViewAddItem(INT ItemIndex, INT IconIndex, LPWSTR lpText, LPARAM lParam)
 {
     LV_ITEMW Item;
 
-    ZeroMemory(&Item, sizeof(LV_ITEM));
+    ZeroMemory(&Item, sizeof(Item));
 
     Item.mask       = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
     Item.pszText    = lpText;
@@ -82,11 +82,11 @@ ListViewCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
 
     IndexInfo.lParam = lParam1;
     Index = ListView_FindItem(hListView, -1, &IndexInfo);
-    ListView_GetItemText(hListView, Index, (INT)lParamSort, Item1, sizeof(Item1) / sizeof(WCHAR));
+    ListView_GetItemText(hListView, Index, (INT)lParamSort, Item1, _countof(Item1));
 
     IndexInfo.lParam = lParam2;
     Index = ListView_FindItem(hListView, -1, &IndexInfo);
-    ListView_GetItemText(hListView, Index, (INT)lParamSort, Item2, sizeof(Item2) / sizeof(WCHAR));
+    ListView_GetItemText(hListView, Index, (INT)lParamSort, Item2, _countof(Item2));
 
     if (bAscending)
         return wcscmp(Item2, Item1);
index 8bb8917..2b136a9 100644 (file)
@@ -257,7 +257,7 @@ static BOOL CertIsValid(HINTERNET hInternet, LPWSTR lpszHostName)
             Ret = HttpSendRequestW(hRequest, L"", 0, NULL, 0);
             if (Ret)
             {
-                certInfoLength = sizeof(INTERNET_CERTIFICATE_INFOW);
+                certInfoLength = sizeof(certInfo);
                 Ret = InternetQueryOptionW(hRequest,
                                            INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT,
                                            &certInfo,
@@ -402,7 +402,7 @@ ThreadFunc(LPVOID Context)
     {
         WCHAR szMsgText[MAX_STR_LEN];
 
-        if (!LoadStringW(hInst, IDS_UNABLE_TO_DOWNLOAD, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
+        if (!LoadStringW(hInst, IDS_UNABLE_TO_DOWNLOAD, szMsgText, _countof(szMsgText)))
             goto end;
 
         MessageBoxW(hMainWnd, szMsgText, NULL, MB_OK | MB_ICONERROR);
@@ -440,7 +440,7 @@ ThreadFunc(LPVOID Context)
     {
         WCHAR szMsgText[MAX_STR_LEN];
 
-        if (!LoadStringW(hInst, IDS_CERT_DOES_NOT_MATCH, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
+        if (!LoadStringW(hInst, IDS_CERT_DOES_NOT_MATCH, szMsgText, _countof(szMsgText)))
             goto end;
 
         MessageBoxW(Dlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
@@ -705,7 +705,7 @@ DownloadApplicationsDB(LPWSTR lpUrl)
 {
     APPLICATION_INFO IntInfo;
 
-    ZeroMemory(&IntInfo, sizeof(APPLICATION_INFO));
+    ZeroMemory(&IntInfo, sizeof(IntInfo));
     if (FAILED(StringCbCopyW(IntInfo.szUrlDownload,
                              sizeof(IntInfo.szUrlDownload),
                              lpUrl)))
index b284cee..aade3eb 100644 (file)
@@ -55,7 +55,7 @@ GetSystemColorDepth(VOID)
     DEVMODE pDevMode;
     INT ColorDepth;
 
-    pDevMode.dmSize = sizeof(DEVMODE);
+    pDevMode.dmSize = sizeof(pDevMode);
     pDevMode.dmDriverExtra = 0;
 
     if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &pDevMode))
@@ -143,13 +143,13 @@ SetWelcomeText(VOID)
 {
     WCHAR szText[MAX_STR_LEN*3];
 
-    LoadStringW(hInst, IDS_WELCOME_TITLE, szText, sizeof(szText) / sizeof(WCHAR));
+    LoadStringW(hInst, IDS_WELCOME_TITLE, szText, _countof(szText));
     NewRichEditText(szText, CFE_BOLD);
 
-    LoadStringW(hInst, IDS_WELCOME_TEXT, szText, sizeof(szText) / sizeof(WCHAR));
+    LoadStringW(hInst, IDS_WELCOME_TEXT, szText, _countof(szText));
     InsertRichEditText(szText, 0);
 
-    LoadStringW(hInst, IDS_WELCOME_URL, szText, sizeof(szText) / sizeof(WCHAR));
+    LoadStringW(hInst, IDS_WELCOME_URL, szText, _countof(szText));
     InsertRichEditText(szText, CFM_LINK);
 }
 
@@ -272,7 +272,7 @@ ExtractFilesFromCab(LPWSTR lpCabName, LPWSTR lpOutputPath)
         pfnExtract = (void *) GetProcAddress(hCabinetDll, "Extract");
         if (pfnExtract)
         {
-            ZeroMemory(&Dest, sizeof(SESSION));
+            ZeroMemory(&Dest, sizeof(Dest));
 
             WideCharToMultiByte(CP_ACP, 0, lpOutputPath, -1, Dest.Destination, MAX_PATH, NULL, NULL);
             WideCharToMultiByte(CP_ACP, 0, lpCabName, -1, szCabName, MAX_PATH, NULL, NULL);
@@ -315,7 +315,7 @@ InitLogs(VOID)
         return;
     }
 
-    if (!GetModuleFileName(NULL, szPath, sizeof(szPath) / sizeof(szPath[0])))
+    if (!GetModuleFileNameW(NULL, szPath, _countof(szPath)))
         return;
 
     if (RegSetValueExW(hKey,
index 970a328..4849c6c 100644 (file)
@@ -49,9 +49,9 @@ SetRangeFormatting(LONG Start, LONG End, DWORD dwEffects)
 
     SendMessageW(hRichEdit, EM_SETSEL, Start, End);
 
-    ZeroMemory(&CharFormat, sizeof(CHARFORMAT2));
+    ZeroMemory(&CharFormat, sizeof(CharFormat));
 
-    CharFormat.cbSize = sizeof(CHARFORMAT2);
+    CharFormat.cbSize = sizeof(CharFormat);
     CharFormat.dwMask = dwEffects;
     CharFormat.dwEffects = dwEffects;
 
index f0adcaf..ca4b5ea 100644 (file)
@@ -20,7 +20,7 @@ ChooseFolder(HWND hwnd)
     BROWSEINFO bi;
     WCHAR szPath[MAX_PATH], szBuf[MAX_STR_LEN];
 
-    LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT, szBuf, sizeof(szBuf) / sizeof(TCHAR));
+    LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT, szBuf, _countof(szBuf));
 
     ZeroMemory(&bi, sizeof(bi));
     bi.hwndOwner = hwnd;
@@ -162,7 +162,7 @@ SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
                         LoadStringW(hInst,
                                     IDS_CHOOSE_FOLDER_ERROR,
-                                    szMsgText, sizeof(szMsgText) / sizeof(WCHAR));
+                                    szMsgText, _countof(szMsgText));
 
                         if (MessageBoxW(hDlg, szMsgText, NULL, MB_YESNO) == IDYES)
                         {
index 12e6e9c..8792868 100644 (file)
@@ -123,7 +123,7 @@ CreateHSplitBar(HWND hwnd)
     WCHAR szWindowClass[] = L"HSplitterWindowClass";
     WNDCLASSEXW WndClass = {0};
 
-    WndClass.cbSize        = sizeof(WNDCLASSEXW);
+    WndClass.cbSize        = sizeof(WndClass);
     WndClass.lpszClassName = szWindowClass;
     WndClass.lpfnWndProc   = HSplitterWindowProc;
     WndClass.hInstance     = hInst;
@@ -264,7 +264,7 @@ CreateVSplitBar(HWND hwnd)
     WCHAR szWindowClass[] = L"VSplitterWindowClass";
     WNDCLASSEXW WndClass = {0};
 
-    WndClass.cbSize        = sizeof(WNDCLASSEXW);
+    WndClass.cbSize        = sizeof(WndClass);
     WndClass.lpszClassName = szWindowClass;
     WndClass.lpfnWndProc   = VSplitterWindowProc;
     WndClass.hInstance     = hInst;
index 95f7f77..433d9ac 100644 (file)
@@ -137,7 +137,7 @@ CreateSearchBar(VOID)
 
     SendMessageW(hSearchBar, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
 
-    LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, sizeof(szBuf) / sizeof(WCHAR));
+    LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
     SetWindowTextW(hSearchBar, szBuf);
 
     SetParent(hSearchBar, hToolBar); 
@@ -148,12 +148,12 @@ CreateSearchBar(VOID)
 BOOL
 CreateToolBar(HWND hwnd)
 {
-    INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]);
+    INT NumButtons = _countof(Buttons);
     HIMAGELIST hImageList;
 
-    LoadStringW(hInst, IDS_INSTALL, szInstallBtn, sizeof(szInstallBtn) / sizeof(WCHAR));
-    LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, sizeof(szUninstallBtn) / sizeof(WCHAR));
-    LoadStringW(hInst, IDS_MODIFY, szModifyBtn, sizeof(szModifyBtn) / sizeof(WCHAR));
+    LoadStringW(hInst, IDS_INSTALL, szInstallBtn, _countof(szInstallBtn));
+    LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, _countof(szUninstallBtn));
+    LoadStringW(hInst, IDS_MODIFY, szModifyBtn, _countof(szModifyBtn));
 
     hToolBar = CreateWindowExW(0,
                                TOOLBARCLASSNAMEW,
index 211883c..44642d9 100644 (file)
@@ -15,7 +15,7 @@ TreeViewAddItem(HTREEITEM hParent, LPWSTR lpText, INT Image, INT SelectedImage,
 {
     TV_INSERTSTRUCTW Insert;
 
-    ZeroMemory(&Insert, sizeof(TV_INSERTSTRUCT));
+    ZeroMemory(&Insert, sizeof(Insert));
 
     Insert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
     Insert.hInsertAfter = TVI_LAST;
index 923a5f1..d62e626 100644 (file)
@@ -61,7 +61,7 @@ LoadSettings(VOID)
 
     if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
     {
-        dwSize = sizeof(SETTINGS_INFO);
+        dwSize = sizeof(SettingsInfo);
         if (RegQueryValueExW(hKey, L"Settings", NULL, NULL, (LPBYTE)&SettingsInfo, &dwSize) == ERROR_SUCCESS)
         {
             RegCloseKey(hKey);
@@ -82,7 +82,7 @@ SaveSettings(HWND hwnd)
 
     if (SettingsInfo.bSaveWndPos)
     {
-        wp.length = sizeof(WINDOWPLACEMENT);
+        wp.length = sizeof(wp);
         GetWindowPlacement(hwnd, &wp);
 
         SettingsInfo.Left = wp.rcNormalPosition.left;
@@ -95,7 +95,7 @@ SaveSettings(HWND hwnd)
     if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0, NULL,
         REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
     {
-        RegSetValueExW(hKey, L"Settings", 0, REG_BINARY, (LPBYTE)&SettingsInfo, sizeof(SETTINGS_INFO));
+        RegSetValueExW(hKey, L"Settings", 0, REG_BINARY, (LPBYTE)&SettingsInfo, sizeof(SettingsInfo));
         RegCloseKey(hKey);
     }
 }
@@ -943,7 +943,7 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nSh
     InitCommonControls();
 
     /* Create the window */
-    WndClass.cbSize        = sizeof(WNDCLASSEXW);
+    WndClass.cbSize        = sizeof(WndClass);
     WndClass.lpszClassName = szWindowClass;
     WndClass.lpfnWndProc   = MainWindowProc;
     WndClass.hInstance     = hInstance;
index bb91643..857aa4f 100644 (file)
@@ -10,9 +10,9 @@ public:
 
         SendMessageW(EM_SETSEL, Start, End);
 
-        ZeroMemory(&CharFormat, sizeof(CHARFORMAT2));
+        ZeroMemory(&CharFormat, sizeof(CharFormat));
 
-        CharFormat.cbSize = sizeof(CHARFORMAT2);
+        CharFormat.cbSize = sizeof(CharFormat);
         CharFormat.dwMask = dwEffects;
         CharFormat.dwEffects = dwEffects;
 
index 29a1cda..417835b 100644 (file)
@@ -129,12 +129,12 @@ public:
             { 6, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 }
         };
 
-        INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]);
+        INT NumButtons = _countof(Buttons);
         HIMAGELIST hImageList;
 
-        LoadStringW(hInst, IDS_INSTALL, szInstallBtn, sizeof(szInstallBtn) / sizeof(WCHAR));
-        LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, sizeof(szUninstallBtn) / sizeof(WCHAR));
-        LoadStringW(hInst, IDS_MODIFY, szModifyBtn, sizeof(szModifyBtn) / sizeof(WCHAR));
+        LoadStringW(hInst, IDS_INSTALL, szInstallBtn, _countof(szInstallBtn));
+        LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, _countof(szUninstallBtn));
+        LoadStringW(hInst, IDS_MODIFY, szModifyBtn, _countof(szModifyBtn));
 
         m_hWnd = CreateWindowExW(0,
             TOOLBARCLASSNAMEW,
@@ -213,7 +213,7 @@ public:
             ItemIndex = Index;
         }
 
-        ZeroMemory(&Item, sizeof(LVITEM));
+        ZeroMemory(&Item, sizeof(Item));
 
         Item.mask = LVIF_PARAM;
         Item.iItem = ItemIndex;
@@ -227,7 +227,7 @@ public:
     {
         LV_COLUMN Column;
 
-        ZeroMemory(&Column, sizeof(LV_COLUMN));
+        ZeroMemory(&Column, sizeof(Column));
 
         Column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
         Column.iSubItem = Index;
@@ -242,7 +242,7 @@ public:
     {
         LV_ITEMW Item;
 
-        ZeroMemory(&Item, sizeof(LV_ITEM));
+        ZeroMemory(&Item, sizeof(Item));
 
         Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
         Item.pszText = lpText;
@@ -269,11 +269,11 @@ public:
 
         IndexInfo.lParam = lParam1;
         Index = FindItem(-1, &IndexInfo);
-        GetItemText(Index, iSubItem, Item1, sizeof(Item1) / sizeof(WCHAR));
+        GetItemText(Index, iSubItem, Item1, _countof(Item1));
 
         IndexInfo.lParam = lParam2;
         Index = FindItem(-1, &IndexInfo);
-        GetItemText(Index, iSubItem, Item2, sizeof(Item2) / sizeof(WCHAR));
+        GetItemText(Index, iSubItem, Item2, _countof(Item2));
 
         if (bAscending)
             return wcscmp(Item2, Item1);
@@ -510,7 +510,7 @@ private:
 
         m_SearchBar->SendMessageW(WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
 
-        LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, sizeof(szBuf) / sizeof(WCHAR));
+        LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
         m_SearchBar->SetWindowTextW(szBuf);
 
         return hwnd != NULL;
index 5d309f1..cdff0a2 100644 (file)
@@ -104,10 +104,10 @@ UninstallApplication(INT Index, BOOL bModify)
         ItemIndex = Index;
     }
 
-    ListView_GetItemText(hListView, ItemIndex, 0, szAppName, sizeof(szAppName) / sizeof(WCHAR));
+    ListView_GetItemText(hListView, ItemIndex, 0, szAppName, _countof(szAppName));
     WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szAppName);
 
-    ZeroMemory(&Item, sizeof(LVITEM));
+    ZeroMemory(&Item, sizeof(Item));
 
     Item.mask = LVIF_PARAM;
     Item.iItem = ItemIndex;
@@ -149,7 +149,7 @@ ShowInstalledAppInfo(INT Index)
 #define GET_INFO(a, b, c, d) \
     if (GetApplicationString(Info->hSubKey, a, szInfo)) \
     { \
-        LoadStringW(hInst, b, szText, sizeof(szText) / sizeof(WCHAR)); \
+        LoadStringW(hInst, b, szText, _countof(szText)); \
         InsertRichEditText(szText, c); \
         InsertRichEditText(szInfo, d); \
     } \
@@ -190,8 +190,8 @@ RemoveAppFromRegistry(INT Index)
     Info = (PINSTALLED_INFO) ListViewGetlParam(Index);
     if (!Info || !Info->hSubKey || (ItemIndex == -1)) return;
 
-    if (!LoadStringW(hInst, IDS_APP_REG_REMOVE, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)) ||
-        !LoadStringW(hInst, IDS_INFORMATION, szMsgTitle, sizeof(szMsgTitle) / sizeof(WCHAR)))
+    if (!LoadStringW(hInst, IDS_APP_REG_REMOVE, szMsgText, _countof(szMsgText)) ||
+        !LoadStringW(hInst, IDS_INFORMATION, szMsgTitle, _countof(szMsgTitle)))
         return;
 
     if (MessageBoxW(hMainWnd, szMsgText, szMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
@@ -204,7 +204,7 @@ RemoveAppFromRegistry(INT Index)
             return;
         }
 
-        if (!LoadStringW(hInst, IDS_UNABLE_TO_REMOVE, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
+        if (!LoadStringW(hInst, IDS_UNABLE_TO_REMOVE, szMsgText, _countof(szMsgText)))
             return;
 
         MessageBoxW(hMainWnd, szMsgText, NULL, MB_OK | MB_ICONERROR);
index 9d6982f..ccac39f 100644 (file)
@@ -212,7 +212,7 @@ static BOOL CertIsValid(HINTERNET hInternet, LPWSTR lpszHostName)
             Ret = HttpSendRequestW(hRequest, L"", 0, NULL, 0);
             if (Ret)
             {
-                certInfoLength = sizeof(INTERNET_CERTIFICATE_INFOW);
+                certInfoLength = sizeof(certInfo);
                 Ret = InternetQueryOptionW(hRequest,
                                            INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT,
                                            &certInfo,
@@ -351,7 +351,7 @@ ThreadFunc(LPVOID Context)
     {
         WCHAR szMsgText[MAX_STR_LEN];
 
-        if (!LoadStringW(hInst, IDS_UNABLE_TO_DOWNLOAD2, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
+        if (!LoadStringW(hInst, IDS_UNABLE_TO_DOWNLOAD2, szMsgText, _countof(szMsgText)))
             goto end;
 
         MessageBoxW(hMainWnd, szMsgText, NULL, MB_OK | MB_ICONERROR);
@@ -365,7 +365,7 @@ ThreadFunc(LPVOID Context)
     {
         WCHAR szMsgText[MAX_STR_LEN];
 
-        if (!LoadStringW(hInst, IDS_UNABLE_TO_DOWNLOAD, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
+        if (!LoadStringW(hInst, IDS_UNABLE_TO_DOWNLOAD, szMsgText, _countof(szMsgText)))
             goto end;
 
         MessageBoxW(hMainWnd, szMsgText, NULL, MB_OK | MB_ICONERROR);
@@ -403,7 +403,7 @@ ThreadFunc(LPVOID Context)
     {
         WCHAR szMsgText[MAX_STR_LEN];
 
-        if (!LoadStringW(hInst, IDS_CERT_DOES_NOT_MATCH, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
+        if (!LoadStringW(hInst, IDS_CERT_DOES_NOT_MATCH, szMsgText, _countof(szMsgText)))
             goto end;
 
         MessageBoxW(Dlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
@@ -664,7 +664,7 @@ DownloadApplicationsDB(LPCWSTR lpUrl)
 {
     APPLICATION_INFO IntInfo;
 
-    ZeroMemory(&IntInfo, sizeof(APPLICATION_INFO));
+    ZeroMemory(&IntInfo, sizeof(IntInfo));
     if (FAILED(StringCbCopyW(IntInfo.szUrlDownload,
                              sizeof(IntInfo.szUrlDownload),
                              lpUrl)))
index 62860ff..8a5cbc3 100644 (file)
@@ -55,7 +55,7 @@ GetSystemColorDepth(VOID)
     DEVMODE pDevMode;
     INT ColorDepth;
 
-    pDevMode.dmSize = sizeof(DEVMODE);
+    pDevMode.dmSize = sizeof(pDevMode);
     pDevMode.dmDriverExtra = 0;
 
     if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &pDevMode))
@@ -143,13 +143,13 @@ SetWelcomeText(VOID)
 {
     WCHAR szText[MAX_STR_LEN*3];
 
-    LoadStringW(hInst, IDS_WELCOME_TITLE, szText, sizeof(szText) / sizeof(WCHAR));
+    LoadStringW(hInst, IDS_WELCOME_TITLE, szText, _countof(szText));
     NewRichEditText(szText, CFE_BOLD);
 
-    LoadStringW(hInst, IDS_WELCOME_TEXT, szText, sizeof(szText) / sizeof(WCHAR));
+    LoadStringW(hInst, IDS_WELCOME_TEXT, szText, _countof(szText));
     InsertRichEditText(szText, 0);
 
-    LoadStringW(hInst, IDS_WELCOME_URL, szText, sizeof(szText) / sizeof(WCHAR));
+    LoadStringW(hInst, IDS_WELCOME_URL, szText, _countof(szText));
     InsertRichEditText(szText, CFM_LINK);
 }
 
@@ -272,7 +272,7 @@ ExtractFilesFromCab(LPWSTR lpCabName, LPWSTR lpOutputPath)
         pfnExtract = (fnExtract) GetProcAddress(hCabinetDll, "Extract");
         if (pfnExtract)
         {
-            ZeroMemory(&Dest, sizeof(SESSION));
+            ZeroMemory(&Dest, sizeof(Dest));
 
             WideCharToMultiByte(CP_ACP, 0, lpOutputPath, -1, Dest.Destination, MAX_PATH, NULL, NULL);
             WideCharToMultiByte(CP_ACP, 0, lpCabName, -1, szCabName, MAX_PATH, NULL, NULL);
@@ -315,7 +315,7 @@ InitLogs(VOID)
         return;
     }
 
-    if (!GetModuleFileName(NULL, szPath, sizeof(szPath) / sizeof(szPath[0])))
+    if (!GetModuleFileNameW(NULL, szPath, _countof(szPath)))
         return;
 
     if (RegSetValueExW(hKey,
index 33d34eb..728dc87 100644 (file)
@@ -20,7 +20,7 @@ ChooseFolder(HWND hwnd)
     BROWSEINFO bi;
     WCHAR szPath[MAX_PATH], szBuf[MAX_STR_LEN];
 
-    LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT, szBuf, sizeof(szBuf) / sizeof(TCHAR));
+    LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT, szBuf, _countof(szBuf));
 
     ZeroMemory(&bi, sizeof(bi));
     bi.hwndOwner = hwnd;
@@ -162,7 +162,7 @@ SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
                         LoadStringW(hInst,
                                     IDS_CHOOSE_FOLDER_ERROR,
-                                    szMsgText, sizeof(szMsgText) / sizeof(WCHAR));
+                                    szMsgText, _countof(szMsgText));
 
                         if (MessageBoxW(hDlg, szMsgText, NULL, MB_YESNO) == IDYES)
                         {
index 7d6fba5..4198c21 100644 (file)
@@ -123,7 +123,7 @@ CreateHSplitBar(HWND hwnd)
     WCHAR szWindowClass[] = L"HSplitterWindowClass";
     WNDCLASSEXW WndClass = {0};
 
-    WndClass.cbSize        = sizeof(WNDCLASSEXW);
+    WndClass.cbSize        = sizeof(WndClass);
     WndClass.lpszClassName = szWindowClass;
     WndClass.lpfnWndProc   = HSplitterWindowProc;
     WndClass.hInstance     = hInst;
@@ -264,7 +264,7 @@ CreateVSplitBar(HWND hwnd)
     WCHAR szWindowClass[] = L"VSplitterWindowClass";
     WNDCLASSEXW WndClass = {0};
 
-    WndClass.cbSize        = sizeof(WNDCLASSEXW);
+    WndClass.cbSize        = sizeof(WndClass);
     WndClass.lpszClassName = szWindowClass;
     WndClass.lpfnWndProc   = VSplitterWindowProc;
     WndClass.hInstance     = hInst;
index 795952c..4627d03 100644 (file)
@@ -78,7 +78,7 @@ LoadSettings(VOID)
 
     if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
     {
-        dwSize = sizeof(SETTINGS_INFO);
+        dwSize = sizeof(SettingsInfo);
         if (RegQueryValueExW(hKey, L"Settings", NULL, NULL, (LPBYTE)&SettingsInfo, &dwSize) == ERROR_SUCCESS)
         {
             RegCloseKey(hKey);
@@ -99,7 +99,7 @@ SaveSettings(HWND hwnd)
 
     if (SettingsInfo.bSaveWndPos)
     {
-        wp.length = sizeof(WINDOWPLACEMENT);
+        wp.length = sizeof(wp);
         GetWindowPlacement(hwnd, &wp);
 
         SettingsInfo.Left = wp.rcNormalPosition.left;
@@ -112,7 +112,7 @@ SaveSettings(HWND hwnd)
     if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0, NULL,
         REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
     {
-        RegSetValueExW(hKey, L"Settings", 0, REG_BINARY, (LPBYTE)&SettingsInfo, sizeof(SETTINGS_INFO));
+        RegSetValueExW(hKey, L"Settings", 0, REG_BINARY, (LPBYTE)&SettingsInfo, sizeof(SettingsInfo));
         RegCloseKey(hKey);
     }
 }