• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


28 Apr, 2025

Updated at 18 May, 2025

Sort ListView with ULARGE_INTEGER-based Size/Date columns

I'm displaying a File ListView which has the columns Size and Date. The WIN32_FIND_DATA structure used to find files specifies (1) Size as nFileSizeHigh/nFileSizeLow, and (2) Date via FILETIME as dwLowDateTime/dwHighDateTime.

These are meant to be combined into ULARGE_INTEGER as e.g.

uLargeInteger.LowPart = low;
uLargeInteger.HighPart = high;
// Final value
ULONGLONG final = uLargeInteger.QuadPart;

Once added into the ListView these are strings. (1) The Size is goes into LVITEM's pszTest as std::towstring(sizeULastInteger.QuadPart, (2) The Date via SHFormatDate().

To sort the ListView, I define the comparator function int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM sortParam) which has to convert the strings back into numbers for comparison.

  1. For the size, I can test std::stoi(wstr) (assuming there won't be any int issues in modern environments, Windows 10+)
  2. For the Date, obtained with SHFormatDate, is there an easy way to convert back? I can either maintain a parallel data struct with the underlying ULARGE_INTEGER, or use C++'s date/time libraries but that assumes a local pattern.

Note: The only answers available on Google on this are for WPF and C#.