3

I am trying to properly integrate our app with the Windows 7 Jump Lists. We allow opening files within the application and I added this a while ago to add the items to the jump list:

var list = JumpList.CreateJumpList()
list.AddToRecent(file);
list.Refresh();

where JumpList is from the WindowsAPICodePack

There were two issues with this approach.

  1. Occasionally users would get a ComException on the Refresh() call (Unable to remove the file to be replaced. (Exception from HRESULT: 0x80070497)).
  2. The JumpList would only contain files with the applications file extension.

We allow importing other files in our application via the Open method and I want these files to also show up in the Jump List but they don't.

I searched through the questions regarding JumpLists here on SO and found a different way to add recently used files in this answer:

    void AddFileToRecentFilesList(string fileName)
    {
        SHAddToRecentDocs((uint)ShellAddRecentDocs.SHARD_PATHW, fileName);          
    }

    /// <summary>
    /// Native call to add the file to windows' recent file list
    /// </summary>
    /// <param name="uFlags">Always use (uint)ShellAddRecentDocs.SHARD_PATHW</param>
    /// <param name="pv">path to file</param>
    [DllImport("shell32.dll")]
    public static extern void SHAddToRecentDocs(UInt32 uFlags,
        [MarshalAs(UnmanagedType.LPWStr)] String pv);

    enum ShellAddRecentDocs
    {
        SHARD_PIDL = 0x00000001,
        SHARD_PATHA = 0x00000002,
        SHARD_PATHW = 0x00000003
    }

This seemed more appropriate as it is also backwards compatible with XP, Vista - Problem is that the JumpList still only contains files with my associated file extension.

I have two questions:

  1. What is the better way to add items to the Jump List.
  2. How do I get any file to show up on my Jump List, regardless of file extension?
4

1 に答える 1

4

MSDNから:

アプリケーションは、そのタイプのアイテムがジャンプリストに表示されるように、ファイルタイプの登録済みハンドラーである必要があります。ただし、そのファイルタイプのデフォルトハンドラである必要はありません。

したがって、ProgIdに動詞を追加するか、OpenWithProgIdsまたはOpenWithList(HKCR \%。ext%\ OpenWithProgIds)にProgIdまたはexe名を追加するだけで、気になるすべてのファイルタイプに自分で登録を追加する必要があります。

Windowsがこれを必要とするという事実は少しばかげた私見ですが、ジャンプリストアイテムをクリックしたときにファイルパスをアプリに渡す方法を知っている必要があると思います。

SHAddToRecentDocsには、リストしたよりも多くのパラメータータイプがあります。SHARDAPPIDINFOLINKのドキュメントには、基本パスを追加する代わりに、どこかに登録する必要があるかどうかが記載されていないため、登録する必要があります...

于 2011-03-28T04:20:42.590 に答える