public static void AddToRecentCategory(JumpTask jumpTask) { Verify.IsNotNull <JumpTask>(jumpTask, "jumpTask"); if (Utilities.IsOSWindows7OrNewer) { IShellLinkW shellLinkW = JumpList.CreateLinkFromJumpTask(jumpTask, false); try { if (shellLinkW != null) { NativeMethods2.SHAddToRecentDocs(shellLinkW); } } finally { Utilities.SafeRelease <IShellLinkW>(ref shellLinkW); } } }
/// <summary> /// Add the task at the specified file path to the application's JumpList's recent items. /// </summary> /// <remarks> /// This makes the item eligible for inclusion in the special Recent and Frequent categories. /// </remarks> public static void AddToRecentCategory(JumpTask jumpTask) { Verify.IsNotNull(jumpTask, "jumpTask"); // SHAddToRecentDocs only allows IShellLinks in Windows 7 and later. // Silently fail this if that's not the case. // We don't give feedback on success here, so this is okay. if (Utilities.IsOSWindows7OrNewer) { IShellLinkW shellLink = CreateLinkFromJumpTask(jumpTask, false); try { if (shellLink != null) { NativeMethods2.SHAddToRecentDocs(shellLink); } } finally { Utilities.SafeRelease(ref shellLink); } } }
/// <summary> /// Add the item at the specified file path to the application's JumpList's recent items. /// </summary> /// <remarks> /// This makes the item eligible for inclusion in the special Recent and Frequent categories. /// </remarks> public static void AddToRecentCategory(string itemPath) { Verify.FileExists(itemPath, "itemPath"); itemPath = Path.GetFullPath(itemPath); NativeMethods2.SHAddToRecentDocs(itemPath); }