$ show henrypp/memreduct
MemReduct is a Windows desktop application for real-time memory monitoring and cleaning, implemented in C with the Win32 API and the undocumented Native API. It operates as a system tray utility that can manually or automatically purge various Windows memory caches: working sets, standby list, modified page list, system file cache, registry cache (Win8.1+), and combined memory lists (Win10+). The core cleaning logic uses NtSetSystemInformation with specific information classes, supplemented by volume cache flushing via the MOUNTMGR device. The application requires administrator privileges for full functionality and provides a configuration GUI with settings for auto-clean thresholds, intervals, hotkeys, language selection, and tray icon appearance. The architecture is monolithic: a single executable built from source files (main.c, main.h, resource files) that links against a reusable utility library (the 'routine' submodule). This library abstracts common Win32 tasks such as registry/INI config management, localization via .ini files, custom listview controls, theme handling, and device context operations. The application entry point is wWinMain in main.c, which creates the main dialog and processes window messages via DlgProc. Memory status is polled every second via a timer callback, and cleaning actions are triggered either manually through the UI or automatically based on user-defined thresholds. External dependencies are limited to Windows system DLLs (kernel32, user32, ntdll, advapi32) and the two submodules: 'routine' (utility code) and 'builder' (installer packaging). The build system uses Visual Studio 2017 project files with batch scripts for x86, x64, and ARM64 targets. No network dependencies exist except an optional update check. The codebase demonstrates non-obvious skill in low-level Windows system programming, custom GDI tray icon rendering, and conditional feature compilation, but remains maintainable through its separation of concerns in the routine library.
The LLM identified 2 files worth highlighting for reuse:
The 'routine' submodule is a standalone C library that encapsulates common Windows application patterns: configuration storage (registry/INI), locale loading from INI files, custom listview control, tray icon management, theme support, and GDI device context helpers. It is imported into the main project via a submodule and could be extracted and reused in other Win32 applications with minimal modification.
These functions implement a custom tray icon that dynamically displays a percentage value (free memory percentage). They create an icon using a memory device context (CreateCompatibleDC), draw text onto a mask bitmap, and then use CreateIconIndirect to produce an alpha-blended icon. This pattern is non-obvious and reusable for any Windows application that needs a dynamic tray icon with custom graphics.