[DllImport("shell32.dll", CharSet = CharSet.Ansi)]
public static extern void SHAddToRecentDocs(ShellAddToRecentDocsFlags flag, string path);
[DllImport("shell32.dll")]
public static extern void SHAddToRecentDocs(ShellAddToRecentDocsFlags flag, IntPtr pidl);
public enum ShellAddToRecentDocsFlags {
Pidl = 0x001,
Path = 0x002,
}
None.
Helper:
public static void AddToRecentDocs(string path) {
SHAddToRecentDocs(ShellAddToRecentDocsFlags.Path, path);
}
class ShellApi {
public enum ShellAddToRecentDocsFlags {
Pidl = 0x001,
Path = 0x002,
}
[DllImport("shell32.dll", CharSet = CharSet.Ansi)]
public static extern void
SHAddToRecentDocs(ShellAddToRecentDocsFlags flag, string path);
[DllImport("shell32.dll")]
public static extern void
SHAddToRecentDocs(ShellAddToRecentDocsFlags flag, IntPtr pidl);
public static void AddToRecentDocs(string path) {
SHAddToRecentDocs(ShellAddToRecentDocsFlags.Path, path);
}
}
class MainForm : Form {
...
void OpenDocument(string newFilename) {
...
// Put the file into the Start->Documents list
ShellApi.AddToRecentDocs(newFilename);
}
void SaveDocument(string newFilename) {
...
// Put the file into the Start->Documents list
ShellApi.AddToRecentDocs(newFilename);
}
...
}
Do you know one? Please contribute it!
Chris Sells (csells@sellsbrothers.com).