Solved

Programmatically add files to Start Menu's "My Recent Documents" list

Posted on 2008-10-15
9
1,066 Views
Last Modified: 2013-11-20
How do I add files to the "My Recent Documents" list from within an MFC Windows C++ program ?

Whenever I Open/Save a file using the CFileDialog, it adds it OK. Whenever I open my application by clicking on one of its specific file types, it adds it OK. All this happens without me doing anything special.

When I open a file with drag/drop onto my application, that filename does not get added to the MRD list.

I am maintaining my own in-program Most Recently Used File list, and that works OK.
It's the MRD list on the Start Menu that I'm interested in.

Actually, this might not be an MFC thing; it might be a pure Windows API thing.
0
Comment
Question by:muttley3141
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
9 Comments
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 22724812
This KB article might be helpful http://support.microsoft.com/kb/243751
0
 
LVL 1

Author Comment

by:muttley3141
ID: 22725559
LOP: No, this isn't what I'm looking for. I'd already come across that Knowledge Base article. That article deals with handling the PROGRAM's MRU List. I'm interested in manipulating the one on the Start Menu. It's possible that using the former using the method implied in that KB Article automatically manages the latter. However, I'm managing this sort of thing myself.

I'd've thought there'd be a simple BOOL WINAPI AddFileToRecentDocumentsList(LPCTSTR *s) but there isn't.
0
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 22726752
Sorry, I am also not aware of such a function in the Windows API, the closest other information that might possibly be helpful is a C# project at http://www.codeproject.com/KB/cs/PruneMyRecentDocuments.aspx and a thread at http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/e48e9e81-2a78-4a07-a427-5ff0ced74d3d/ however someone might have a better suggestion.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:muttley3141
ID: 22726958
Yes, I thought about manipulating the registry directly but I'm not convinced it's going to be in the same place or in the same format on all versions of Windows.

I'd already seen that piece on The Code Project.

I think what I'm going to try and do is to create a dummy CFileDialog, keep it invisible, and see if that "works" as a surrogate to writing to the MRD list.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 22741662

SHAddToRecentDocs Function


Adds a document to the Shell's list of recently used documents or clears all documents from the list.
Syntax
void SHAddToRecentDocs(      
    UINT uFlags,SHAddToRecentDocs Function   
Adds a document to the Shell's list of recently used documents or clears all  documents from the list.  
Syntax void SHAddToRecentDocs(      
    UINT uFlags,
    LPCVOID pv
); 
Parameters  uFlags [in] Flag that indicates the meaning of the pv parameter. This flag  can be one of the following values:  SHARD_PATH The pv parameter points to a null-terminated string with the path and  file name of the object. SHARD_PIDL The pv parameter points to a pointer to an item identifier list  (PIDL) that identifies the document's file object. PIDLs that identify non-file  objects are not allowed. pv [in] A pointer to either a null-terminated string with the path and file  name of the document, or a PIDL that identifies the document's file object. Set  this parameter to NULL to clear all documents from the list.  

    LPCVOID pv
);

Open in new window

Parameters
uFlags[in] Flag that indicates the meaning of the pv parameter. This flag can be one of the following values: SHARD_PATHThe pv parameter points to a null-terminated string with the path and file name of the object.SHARD_PIDLThe pv parameter points to a pointer to an item identifier list (PIDL) that identifies the document's file object. PIDLs that identify non-file objects are not allowed.pv[in] A pointer to either a null-terminated string with the path and file name of the document, or a PIDL that identifies the document's file object. Set this parameter to NULL to clear all documents from the list.
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 165 total points
ID: 22741675
Lets see if removing the formatting helps



SHAddToRecentDocs Function  
Adds a document to the Shell's list of recently used documents or clears all  documents from the list.  
Syntax void SHAddToRecentDocs(      
    UINT uFlags,
    LPCVOID pv
);
Parameters  uFlags [in] Flag that indicates the meaning of the pv parameter. This flag  can be one of the following values:  SHARD_PATH The pv parameter points to a null-terminated string with the path and  file name of the object. SHARD_PIDL The pv parameter points to a pointer to an item identifier list  (PIDL) that identifies the document's file object. PIDLs that identify non-file  objects are not allowed. pv [in] A pointer to either a null-terminated string with the path and file  name of the document, or a PIDL that identifies the document's file object. Set  this parameter to NULL to clear all documents from the list.  
0
 
LVL 19

Assisted Solution

by:LordOfPorts
LordOfPorts earned 35 total points
ID: 22742503
Respect to Andy for finding the function http://msdn.microsoft.com/en-us/library/bb762105(VS.85).aspx
0
 
LVL 1

Author Comment

by:muttley3141
ID: 22742955
OK. Thank you Andy. It wasn't an obviously-named function, which is what caused me to miss it.
Thank you also LOP for getting the KB article, which references the other interesting SH.. functions.

BTW, does anybody know if it's possible to leave a "tip", i.e. leaving more points than originally agreed, if some contributor goes A+BTCoD, such as providing lots of background knowledge that turned out to be very useful, but which was not explicitly asked for in the original question ?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 22743066
Yeah, just increase the points for the question BEFORE hitting the accept button.

If you want afterwards then post a request in community support for the question to be reopened and your reasons why.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Line meaning 9 91
Task with PowerShell Script is failing with 0x41301 7 124
MS-Access 2002 error (Win XP on Win7Pro) 19 110
Increment column based of a FK 8 51
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question