Share via

How to get recent docs list and delete some of them using windows api?

Steins 41 Reputation points
Nov 14, 2022, 1:55 PM

I'm trying to write a script to get windows recent docs and try delete some of them using rust.

  1. Be aware that i can add one or clear all using winsafe::SHAddToRecentDocs.
  2. Found that recent files will be stored at C:\Users\xx\AppData\Roaming\Microsoft\Windows\Recent, particularly f01b4d95cf55d32a.automaticDestinations-ms.
  3. Check the automaticDestinations-ms file with winhex, did found some recent access path.
  4. Since windows allows us right click on recent files and 'remove from quick access', there supposed to be an api do this job, failed to found it.
  5. Keeping search and found some says they been saved at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs, checked and found not easy to understand them.

So here's my question:

  1. How to get recent files list? Like the file explorer did.
  2. How to remove some items from it? Like the button 'remove from quick access' did.
  3. How to disable 'Show recently used files in quick access' or 'show frequently used folders in quick access'?
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,698 questions
{count} votes

Accepted answer
  1. Castorix31 86,396 Reputation points
    Nov 14, 2022, 4:46 PM

    It can be done with the Shell by enumerating items from "shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}" like I did in this thread
    To remove an item, it is the menu command "unpinfromhome", although, from my tests (Windows 10 21H1), for files I have to get the localized description ("Supprimer de l'accès rapide" on my french OS from GetMenuString) then the ID with GetMenuItemInfo and MIIM_ID, then ici.lpVerb = (IntPtr)(ID - 1) for InvokeCommand

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.