Desktop GUI tip: working with Windows shell MRU lists

Posted: (EET/GMT+2)

 

Even in 2025, desktop development is far from dead, so a tip post is in order. If you build desktop applications on Windows, you can sometimes improve the user experience by integrating with Windows shell MRU lists (Most Recently Used). These appear in many places: File Explorer's recent files list, common dialogs, Run dialog history, and so on.

There are two ways to work with MRU lists in Windows shell: modifying the registry directly, or using a slightly obscure Win32 API function called CreateMRUListW. What's interesting is that while this API function is documented, there's no .h header file for native C/C++ folks. In this article, we'll investigate the registry methods (and possibly, the Win32 API function in a future post.)

Windows stores many of these MRU entries in the registry. For example:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

Each entry corresponds to a command the user typed in the Run dialog. For applications that interact with system paths, documents or tools, reading these lists can help provide "smart defaults" or quick access options.

Reading MRU keys in C# can be done with a little registry magic. More precisely, you can read an MRU list simply using the Microsoft.Win32.RegistryKey class:

using Microsoft.Win32;

var key = Registry.CurrentUser.OpenSubKey(
    @"Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU");

if (key != null)
{
    foreach (var valueName in key.GetValueNames())
    {
        string? entry = key.GetValue(valueName)?.ToString();
        if (!string.IsNullOrWhiteSpace(entry))
        {
            Console.WriteLine($"{valueName}: {entry}");
        }
    }
}

This gives you the entries in the order Windows stores them internally. You can then use them to pre-populate dropdowns, autocomplete fields or quick-select lists.

While reading MRU lists is generally safe, writing to them should be done carefully, as Windows Explorer and other shell components rely on specific formatting. If you write your entries wrong, the user might lose all entries in the history list. For most scenarios it's better to keep writes inside your own application's MRU logic and only read shell MRU lists when you want to provide suggestions.

Useful MRU locations

  • RunMRU: Run dialog history
  • ComDlg32: Common File Open/Save dialog MRU entries
  • RecentDocs: File Explorer's recent files

This is one of those small Windows integration tricks that can help make your desktop application feel more polished and "native" on Windows. Sometimes these tiny touches make a big difference.

Happy shell coding!