「explorer.exe」を開くことをジャンプタスクとして登録したい32ビットアプリケーションがあります。32 ビットの Windows 7 では問題なく動作しますが、64 ビットの Windows では「C:\Windows\system32\explorer.exe Unspecified error」というエラーが発生します。
Explorer のフル パスは「C:\Windows\SysWOW64\explorer.exe」であるため、Windows が実行時にエミュレートされた 32 ビット パスを認識した結果であると推測しますが、ジャンプ リストには 64 ビットのフル パスが必要です。64 ビット OS で動作するこのジャンプリストを作成する簡単な方法はありますか?
Environment.Is64BitOperatingSystem のチェックを行い、設定されている場合は場所を「C:\Windows\SysWow64」にハードコーディングできると思いますが、ハードコーディングされたパスを使用するのは悪いことです。
string exe = System.Reflection.Assembly.GetExecutingAssembly().Location;
string current = System.IO.Path.GetDirectoryName(exe);
var jl = new System.Windows.Shell.JumpList();
jl.ShowFrequentCategory = false;
jl.ShowRecentCategory = false;
jl.BeginInit();
jl.JumpItems.AddRange(new[]
{
new System.Windows.Shell.JumpTask
{
Title = "Explore",
ApplicationPath = "explorer.exe",
IconResourcePath = "explorer.exe",
Arguments = "/select,\"" + exe,
WorkingDirectory = current,
},
// other jump tasks here
});
jl.EndInit();
jl.Apply();