【问题标题】:Opening explorer.exe from a jump task using 32 bit task on 64 bit OS在 64 位操作系统上使用 32 位任务从跳转任务中打开 explorer.exe
【发布时间】:2013-04-03 13:40:48
【问题描述】:

我有一个 32 位应用程序,我想注册打开“explorer.exe”作为跳转任务。它在 32 位 Windows 7 上运行良好,但在 64 位 Windows 中,它会给出错误“C:\Windows\system32\explorer.exe Unspecified error”。

由于资源管理器的完整路径是“C:\Windows\SysWOW64\explorer.exe”,我认为这是 Windows 在运行时看到 32 位模拟路径的结果,但跳转列表需要完整的 64 位路径.有没有一种简单的方法来构建这个可以在 64 位操作系统上运行的跳转列表?

我想我可以检查 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();

【问题讨论】:

    标签: .net windows-7 32bit-64bit jump-list


    【解决方案1】:

    我在这里找到了答案How to start a 64-bit process from a 32-bit process

    “sysnative”在这种情况下不起作用,但暂时禁用文件系统重定向可以:

    [DllImport("kernel32.dll", SetLastError = true)]
    private static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
    [DllImport("kernel32.dll", SetLastError = true)]
    private static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
    
        if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
            Wow64DisableWow64FsRedirection(ref ptr);
        try
        {
            // Add jump list code
        }
        finally
        {
            if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
                Wow64RevertWow64FsRedirection(ptr);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-05
      • 1970-01-01
      • 2012-05-14
      • 2011-10-11
      • 2011-10-01
      • 2013-08-29
      • 2012-07-26
      • 2011-12-18
      相关资源
      最近更新 更多