https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b5368185da117b511c9590dd47a19741fc3f390e

commit b5368185da117b511c9590dd47a19741fc3f390e
Author:     Stanislav Motylkov <x86co...@gmail.com>
AuthorDate: Mon Aug 17 03:18:01 2020 +0300
Commit:     Stanislav Motylkov <x86co...@gmail.com>
CommitDate: Mon Aug 17 03:18:01 2020 +0300

    [SYSDM] Better formatting of user profile size
---
 dll/cpl/sysdm/precomp.h     |  1 +
 dll/cpl/sysdm/userprofile.c | 31 +------------------------------
 2 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/dll/cpl/sysdm/precomp.h b/dll/cpl/sysdm/precomp.h
index 0e6fbde768a..ba296735c9d 100644
--- a/dll/cpl/sysdm/precomp.h
+++ b/dll/cpl/sysdm/precomp.h
@@ -17,6 +17,7 @@
 #include <tchar.h>
 #include <shellapi.h>
 #include <shlobj.h>
+#include <shlwapi.h>
 #include <setupapi.h>
 #include <cpl.h>
 
diff --git a/dll/cpl/sysdm/userprofile.c b/dll/cpl/sysdm/userprofile.c
index 79f76b76225..a4a49589094 100644
--- a/dll/cpl/sysdm/userprofile.c
+++ b/dll/cpl/sysdm/userprofile.c
@@ -433,35 +433,6 @@ GetProfileName(
 }
 
 
-static
-VOID
-FormatProfileSize(
-    _Out_ LPWSTR Buffer,
-    _In_ double size)
-{
-    const LPWSTR units[] = {L"MB", L"GB", L"TB"};
-    int i = 0, j;
-
-    size /= 1024;
-    size /= 1024;
-
-    while (size >= 1024 && i < 3)
-    {
-        size /= 1024;
-        i++;
-    }
-
-    if (size < 10)
-        j = 2;
-    else if (size < 100)
-        j = 1;
-    else
-        j = 0;
-
-    swprintf(Buffer, L"%.*f %s", j, size, units[i]);
-}
-
-
 static VOID
 AddUserProfile(
     _In_ HWND hwndListView,
@@ -585,7 +556,7 @@ AddUserProfile(
     iItem = ListView_InsertItem(hwndListView, &lvi);
 
     /* Set the profile size */
-    FormatProfileSize(szNameBuffer, (double)ullProfileSize);
+    StrFormatByteSizeW(ullProfileSize, szNameBuffer, ARRAYSIZE(szNameBuffer) - 
1);
     ListView_SetItemText(hwndListView, iItem, 1, szNameBuffer);
 
     /* Set the profile type */

Reply via email to