[SYSDM] Better formatting of user profile size

This commit is contained in:
Stanislav Motylkov 2020-08-17 03:18:01 +03:00
parent 1601afd0a6
commit b5368185da
No known key found for this signature in database
GPG key ID: AFE513258CBA9E92
2 changed files with 2 additions and 30 deletions

View file

@ -17,6 +17,7 @@
#include <tchar.h>
#include <shellapi.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <setupapi.h>
#include <cpl.h>

View file

@ -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 */