Windows keeps track of the files you work with ands them to the Start|Documents menu. If you want to add documents to this menu from your program, just use the SHAddToRecentDocs() function. The function requires a PChar parameter but so you can use aways either typecast strings to PChars or use the StrPCopy() function.
uses ShlObj;
...
{ sFileName - the full name of the file you want to add }
SHAddToRecentDocs(SHARD_PATH, PChar(sFileName));
...
Examples:
SHAddToRecentDocs(SHARD_PATH, 'C:\\My Documents\\Notes.txt'); SHAddToRecentDocs(SHARD_PATH, dlgOpen.FileName);
Tags: add, Delphi, documents, file, file name, menu, object pascal, parameter, pchar, start, tip, trick
Merlin’s Delphi Forge
Leave a comment